mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
Fix flaky test_block_mailing_list() (#3733)
Seems like consume_events() didn't work properly, i.e. in some cases it
didn't see the latest events and failed to consume them. So, the
IncomingMsg event from receiving DC_MAILINGLIST stayed in the events
channel, which made this fail:
```rust
// Check that no notification is displayed for blocked mailing list message.
while let Ok(event) = t.evtracker.try_recv() {
assert!(!matches!(event.typ, EventType::IncomingMsg { .. }));
}
```
Fix it by explicitly waiting for the first IncomingMsg event.
This commit is contained in:
@@ -876,9 +876,10 @@ impl EventTracker {
|
||||
.await
|
||||
}
|
||||
|
||||
/// Consumes all pending events.
|
||||
pub fn consume_events(&self) {
|
||||
while self.try_recv().is_ok() {}
|
||||
/// Wait for the next IncomingMsg event.
|
||||
pub async fn wait_next_incoming_message(&self) {
|
||||
self.get_matching(|evt| matches!(evt, EventType::IncomingMsg { .. }))
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user