new clear_events

This commit is contained in:
Simon Laux
2024-04-19 03:55:35 +02:00
parent 47bbcb3cae
commit 4cae52a282
2 changed files with 12 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ use std::collections::{BTreeMap, HashMap};
use std::ffi::OsString;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, Ordering};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;

View File

@@ -785,6 +785,17 @@ impl TestContext {
chat_id
}
/// Clears event queue.
/// Works by emitting a `TestCheckpointEvent` and consuming all events until.
/// times out after 10 seconds.
pub async fn clear_events(&self) {
let event_id = self.emit_test_checkpoint_event().await;
self.evtracker.get_matching(|ev| match ev {
EventType::TestCheckpointEvent { id } => event_id == *id,
_ => false
}).await;
}
}
impl Deref for TestContext {