Skip to content

Commit

Permalink
proper cleanup after potential assertion failure (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 7, 2022
1 parent ac913d8 commit 1f3a600
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,18 @@ mod os_limited {
assert_eq!(remaining, 0);

// They are not in the trash anymore but they should be at their original location
let mut missing = Vec::new();
for path in names.iter() {
assert!(File::open(path).is_ok());
if !std::path::Path::new(&path).is_file() {
missing.push(path);
}
}

// Good ol' remove to clean up
for path in names.iter() {
std::fs::remove_file(path).unwrap();
std::fs::remove_file(path).ok();
}

assert_eq!(missing, Vec::<&String>::new());
}

#[test]
Expand Down

0 comments on commit 1f3a600

Please sign in to comment.