From bd56fa06c16c10ece5548260769fd4630d005f4d Mon Sep 17 00:00:00 2001 From: Malte Tammena Date: Thu, 8 Aug 2024 16:17:55 +0200 Subject: [PATCH] rework failing tests that check time formatting --- src/info/utils/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/info/utils/mod.rs b/src/info/utils/mod.rs index 478a57775..6ed473eb6 100644 --- a/src/info/utils/mod.rs +++ b/src/info/utils/mod.rs @@ -103,24 +103,22 @@ mod tests { } #[test] - #[should_panic( - expected = "Achievement unlocked: time travel! Check your system clock and commit dates." - )] - fn should_panic_when_display_human_time_and_commit_date_in_the_future() { + fn handle_display_human_time_and_commit_date_in_the_future() { let day = Duration::from_secs(60 * 60 * 24); let current_time = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) .unwrap(); let tomorrow = current_time + day; let time = Time::new(tomorrow.as_secs() as gix::date::SecondsSinceUnixEpoch, 0); - format_time(time, false); + let result = format_time(time, false); + assert_eq!(result, "in a day"); } #[test] fn display_time_before_epoch() { let time = Time::new(gix::date::SecondsSinceUnixEpoch::MIN, 0); let result = to_human_time(time); - assert_eq!(result, ""); + assert!(result.ends_with(" years ago")); } #[rstest]