diff --git a/Cargo.lock b/Cargo.lock index f5c8e6e..d6269aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/Cargo.toml b/Cargo.toml index d963339..b66ac2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,4 @@ stop-token = "0.7" [dev-dependencies] textwrap = "0.15.0" +futures-timer = "3.0" diff --git a/src/email.rs b/src/email.rs index 1d28d90..b123402 100644 --- a/src/email.rs +++ b/src/email.rs @@ -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"), }; } }