From 33783d094e7ec94060ef719cabeeb0547d86d389 Mon Sep 17 00:00:00 2001 From: Tanmay Patil Date: Sun, 14 Apr 2024 17:16:53 +0530 Subject: [PATCH] Improve tests --- src/utils.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 4320ed6..7fb48cc 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -163,11 +163,18 @@ mod tests { #[test] fn invalid_file() { + use chrono::{DateTime, Local}; + use std::time::SystemTime; + let invalid_file = "target/utils/invalid-file"; - let m_time = get_modification_time(invalid_file); + // store current time before calling `get_modification_time` + // Because the file is invalid, it will return SystemTime::now() + // which will be greater than previously saved time + let current_time: DateTime = SystemTime::now().into(); + let m_time: DateTime = get_modification_time(invalid_file).parse().unwrap(); - assert!(!m_time.is_empty()); + assert!(m_time > current_time); } } }