mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Update safe_rename with latest changes
This commit is contained in:
parent
b6561a39d4
commit
e020cebf46
1 changed files with 10 additions and 10 deletions
|
@ -565,18 +565,18 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn safe_rename_moves_file() {
|
||||
let dir = tempdir().unwrap();
|
||||
let src = dir.path().join("test_src.txt");
|
||||
let dst = dir.path().join("test_dst.txt");
|
||||
let dir = tempdir().unwrap();
|
||||
let src = dir.path().join("myfile.txt");
|
||||
let dst = dir.path().join("myfile_trashed.txt");
|
||||
|
||||
fs::write(&src, b"hello world").unwrap();
|
||||
safe_rename(&src, &dst).unwrap();
|
||||
fs::write(&src, b"My test content").unwrap();
|
||||
safe_rename(&src, &dst).unwrap();
|
||||
|
||||
assert!(dst.exists());
|
||||
assert!(!src.exists());
|
||||
let contents = fs::read(&dst).unwrap();
|
||||
assert_eq!(contents, b"hello world");
|
||||
assert!(dst.exists());
|
||||
assert!(!src.exists());
|
||||
let contents = fs::read(&dst).unwrap();
|
||||
assert_eq!(contents, b"My test content");
|
||||
|
||||
fs::remove_file(&dst).unwrap();
|
||||
fs::remove_file(&dst).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue