2020-12-13 03:29:54 +00:00
|
|
|
use tokio::runtime::Runtime;
|
|
|
|
|
2020-11-29 18:39:51 +00:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_pretty_print_last_seen () {
|
|
|
|
use LastSeen::*;
|
|
|
|
|
2020-11-29 21:38:23 +00:00
|
|
|
let last_seen = DateTime::parse_from_rfc3339 ("2019-05-29T00:00:00+00:00").expect ("Test case should be RFC3339").with_timezone (&Utc);
|
2020-11-29 18:39:51 +00:00
|
|
|
|
|
|
|
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 () {
|
2020-11-29 21:38:23 +00:00
|
|
|
let now = DateTime::parse_from_rfc3339 (input).expect ("Test case should be RFC3339").with_timezone (&Utc);
|
2020-11-29 18:39:51 +00:00
|
|
|
let actual = pretty_print_last_seen (now, last_seen);
|
|
|
|
assert_eq! (actual, expected);
|
|
|
|
}
|
|
|
|
}
|
2020-12-13 03:29:54 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn scraper_endpoints () {
|
2021-04-18 13:33:07 +00:00
|
|
|
let rt = Runtime::new ().expect ("Can't create runtime for testing");
|
2020-12-13 03:29:54 +00:00
|
|
|
|
|
|
|
rt.block_on (async {
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|