Skip to content

Commit fe8068d

Browse files
committed
Auto merge of #1184 - divergentdave:rename-error-test, r=RalfJung
Test error case of std::fs::rename As suggested [here](#1158 (comment)) this PR adds an additional test case for calling rename on a file path that doesn't exist.
2 parents 056a68d + 32a354e commit fe8068d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/run-pass/fs.rs

+8
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,16 @@ fn test_rename() {
169169

170170
let file = File::create(&path1).unwrap();
171171
drop(file);
172+
173+
// Renaming should succeed
172174
rename(&path1, &path2).unwrap();
175+
// Check that the old file path isn't present
173176
assert_eq!(ErrorKind::NotFound, path1.metadata().unwrap_err().kind());
177+
// Check that the file has moved successfully
174178
assert!(path2.metadata().unwrap().is_file());
179+
180+
// Renaming a nonexistent file should fail
181+
assert_eq!(ErrorKind::NotFound, rename(&path1, &path2).unwrap_err().kind());
182+
175183
remove_file(&path2).unwrap();
176184
}

0 commit comments

Comments
 (0)