Add timeout to broker test
parent
3417870edb
commit
fd6b53a670
|
@ -481,6 +481,12 @@ version = "0.3.21"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a"
|
||||
|
||||
[[package]]
|
||||
name = "futures-timer"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.21"
|
||||
|
@ -1524,6 +1530,7 @@ dependencies = [
|
|||
"async-trait",
|
||||
"derive-getters",
|
||||
"futures",
|
||||
"futures-timer",
|
||||
"log",
|
||||
"mailparse",
|
||||
"serde",
|
||||
|
|
|
@ -27,3 +27,4 @@ stop-token = "0.7"
|
|||
|
||||
[dev-dependencies]
|
||||
textwrap = "0.15.0"
|
||||
futures-timer = "3.0"
|
||||
|
|
|
@ -159,6 +159,7 @@ mod tests {
|
|||
collections::HashMap,
|
||||
fmt::{Display, Formatter},
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::task::{Cancel, SpawnError};
|
||||
|
@ -170,6 +171,7 @@ mod tests {
|
|||
Future, FutureExt, SinkExt,
|
||||
};
|
||||
use futures::{select, StreamExt};
|
||||
use futures_timer::Delay;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
@ -306,6 +308,7 @@ mod tests {
|
|||
select! {
|
||||
msg = message_rx.next() => assert_eq!("hello, world!", msg.expect("empty channel")),
|
||||
_ = join_handle.fuse() => panic!("broker returned, but did not receive message"),
|
||||
_ = Delay::new(Duration::from_secs(5)).fuse() => panic!("test timed out"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue