diff --git a/crates/ptth_relay/src/lib.rs b/crates/ptth_relay/src/lib.rs index 16c23b7..d4d0a96 100644 --- a/crates/ptth_relay/src/lib.rs +++ b/crates/ptth_relay/src/lib.rs @@ -734,7 +734,7 @@ pub async fn run_relay ( shutdown_oneshot.await.ok (); - state.shutdown_watch_tx.broadcast (true).unwrap (); + state.shutdown_watch_tx.broadcast (true).expect ("Can't broadcast graceful shutdown"); let mut response_rendezvous = state.response_rendezvous.write ().await; let mut swapped = DashMap::default (); @@ -763,30 +763,4 @@ pub async fn run_relay ( } #[cfg (test)] -mod tests { - use super::*; - - #[test] - fn test_pretty_print_last_seen () { - use LastSeen::*; - - let last_seen = DateTime::parse_from_rfc3339 ("2019-05-29T00:00:00+00:00").unwrap ().with_timezone (&Utc); - - for (input, expected) in vec! [ - ("2019-05-28T23:59:59+00:00", Negative), - ("2019-05-29T00:00:00+00:00", Connected), - ("2019-05-29T00:00:59+00:00", Connected), - ("2019-05-29T00:01:30+00:00", Description ("1 m ago".into ())), - ("2019-05-29T00:59:30+00:00", Description ("59 m ago".into ())), - ("2019-05-29T01:00:30+00:00", Description ("1 h ago".into ())), - ("2019-05-29T10:00:00+00:00", Description ("10 h ago".into ())), - ("2019-05-30T00:00:00+00:00", Description ("2019-05-29T00:00:00Z".into ())), - ("2019-05-30T10:00:00+00:00", Description ("2019-05-29T00:00:00Z".into ())), - ("2019-05-31T00:00:00+00:00", Description ("2019-05-29T00:00:00Z".into ())), - ].into_iter () { - let now = DateTime::parse_from_rfc3339 (input).unwrap ().with_timezone (&Utc); - let actual = pretty_print_last_seen (now, last_seen); - assert_eq! (actual, expected); - } - } -} +mod tests; diff --git a/crates/ptth_relay/src/tests.rs b/crates/ptth_relay/src/tests.rs new file mode 100644 index 0000000..c1e7b74 --- /dev/null +++ b/crates/ptth_relay/src/tests.rs @@ -0,0 +1,25 @@ +use super::*; + +#[test] +fn test_pretty_print_last_seen () { + use LastSeen::*; + + let last_seen = DateTime::parse_from_rfc3339 ("2019-05-29T00:00:00+00:00").unwrap ().with_timezone (&Utc); + + for (input, expected) in vec! [ + ("2019-05-28T23:59:59+00:00", Negative), + ("2019-05-29T00:00:00+00:00", Connected), + ("2019-05-29T00:00:59+00:00", Connected), + ("2019-05-29T00:01:30+00:00", Description ("1 m ago".into ())), + ("2019-05-29T00:59:30+00:00", Description ("59 m ago".into ())), + ("2019-05-29T01:00:30+00:00", Description ("1 h ago".into ())), + ("2019-05-29T10:00:00+00:00", Description ("10 h ago".into ())), + ("2019-05-30T00:00:00+00:00", Description ("2019-05-29T00:00:00Z".into ())), + ("2019-05-30T10:00:00+00:00", Description ("2019-05-29T00:00:00Z".into ())), + ("2019-05-31T00:00:00+00:00", Description ("2019-05-29T00:00:00Z".into ())), + ].into_iter () { + let now = DateTime::parse_from_rfc3339 (input).unwrap ().with_timezone (&Utc); + let actual = pretty_print_last_seen (now, last_seen); + assert_eq! (actual, expected); + } +}