Skip to content

Commit 33783d0

Browse files
Improve tests
1 parent 900e1c3 commit 33783d0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/utils.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,18 @@ mod tests {
163163

164164
#[test]
165165
fn invalid_file() {
166+
use chrono::{DateTime, Local};
167+
use std::time::SystemTime;
168+
166169
let invalid_file = "target/utils/invalid-file";
167170

168-
let m_time = get_modification_time(invalid_file);
171+
// store current time before calling `get_modification_time`
172+
// Because the file is invalid, it will return SystemTime::now()
173+
// which will be greater than previously saved time
174+
let current_time: DateTime<Local> = SystemTime::now().into();
175+
let m_time: DateTime<Local> = get_modification_time(invalid_file).parse().unwrap();
169176

170-
assert!(!m_time.is_empty());
177+
assert!(m_time > current_time);
171178
}
172179
}
173180
}

0 commit comments

Comments
 (0)