Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmayPatil105 committed Apr 14, 2024
1 parent 900e1c3 commit 33783d0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Local> = SystemTime::now().into();
let m_time: DateTime<Local> = get_modification_time(invalid_file).parse().unwrap();

assert!(!m_time.is_empty());
assert!(m_time > current_time);
}
}
}

0 comments on commit 33783d0

Please sign in to comment.