use tokio::runtime::Runtime; 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").expect ("Test case should be RFC3339").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).expect ("Test case should be RFC3339").with_timezone (&Utc); let actual = pretty_print_last_seen (now, last_seen); assert_eq! (actual, expected); } } #[test] fn scraper_endpoints () { let rt = Runtime::new ().expect ("Can't create runtime for testing"); rt.block_on (async { }); }