mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -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]
|
#[test]
|
||||||
fn safe_rename_moves_file() {
|
fn safe_rename_moves_file() {
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let src = dir.path().join("test_src.txt");
|
let src = dir.path().join("myfile.txt");
|
||||||
let dst = dir.path().join("test_dst.txt");
|
let dst = dir.path().join("myfile_trashed.txt");
|
||||||
|
|
||||||
fs::write(&src, b"hello world").unwrap();
|
fs::write(&src, b"My test content").unwrap();
|
||||||
safe_rename(&src, &dst).unwrap();
|
safe_rename(&src, &dst).unwrap();
|
||||||
|
|
||||||
assert!(dst.exists());
|
assert!(dst.exists());
|
||||||
assert!(!src.exists());
|
assert!(!src.exists());
|
||||||
let contents = fs::read(&dst).unwrap();
|
let contents = fs::read(&dst).unwrap();
|
||||||
assert_eq!(contents, b"hello world");
|
assert_eq!(contents, b"My test content");
|
||||||
|
|
||||||
fs::remove_file(&dst).unwrap();
|
fs::remove_file(&dst).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue