♻️ Remove all practically removable unwraps from ptth_relay
parent
687cffdf90
commit
aad7f8e729
|
@ -734,7 +734,7 @@ pub async fn run_relay (
|
||||||
|
|
||||||
shutdown_oneshot.await.ok ();
|
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 response_rendezvous = state.response_rendezvous.write ().await;
|
||||||
let mut swapped = DashMap::default ();
|
let mut swapped = DashMap::default ();
|
||||||
|
@ -763,30 +763,4 @@ pub async fn run_relay (
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg (test)]
|
#[cfg (test)]
|
||||||
mod tests {
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue