use super::*;
use futures::StreamExt;
#[derive(Clone)]
pub struct DummyTracingKey;
impl TracingKeyStr for DummyTracingKey {
const TRACING_KEY: &'static str = "test_notification_stream";
}
type StringStream = NotificationStream<String, DummyTracingKey>;
#[test]
fn notification_channel_simple() {
let (sender, stream) = StringStream::channel();
let test_payload = String::from("test payload");
let closure_payload = test_payload.clone();
let future = stream.subscribe(100_000).take(1).for_each(move |payload| {
let test_payload = closure_payload.clone();
async move {
assert_eq!(payload, test_payload);
}
});
let r: std::result::Result<(), ()> = sender.notify(|| Ok(test_payload));
r.unwrap();
tokio_test::block_on(future);
}