feat: replace event channel with broadcast channel

This makes `EventTracker` receive events immediately
instead of being moved from event emitter to event tracker
by a task spawned from `TestContext::new_internal`.

This makes `EventTracker.clear_events` reliable
as it is guaranteed to remove all events emitted
by the time it is called rather than only events
that have been moved already.
This commit is contained in:
link2xt
2024-04-19 02:19:21 +00:00
parent 72d5a387fb
commit 34f4ec02f6
11 changed files with 194 additions and 139 deletions

View File

@@ -1007,8 +1007,6 @@ pub fn repeat_vars(count: usize) -> String {
#[cfg(test)]
mod tests {
use async_channel as channel;
use super::*;
use crate::{test_utils::TestContext, EventType};
@@ -1085,8 +1083,7 @@ mod tests {
.await
.unwrap();
let (event_sink, event_source) = channel::unbounded();
t.add_event_sender(event_sink).await;
let event_source = t.get_event_emitter();
let a = t.get_config(Config::Selfavatar).await.unwrap().unwrap();
assert_eq!(avatar_bytes, &tokio::fs::read(&a).await.unwrap()[..]);