Skip to content

Commit 0e1b115

Browse files
committed
test: add case for the symlink file
Signed-off-by: hi-rustin <[email protected]>
1 parent 8b0161e commit 0e1b115

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

crates/cargo-util/src/paths.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,4 +931,27 @@ mod tests {
931931
assert!(symlink_path.exists());
932932
assert!(dir_path.exists());
933933
}
934+
935+
#[test]
936+
#[cfg(windows)]
937+
fn test_remove_symlink_file() {
938+
use super::*;
939+
use std::fs;
940+
use std::os::windows::fs::symlink_file;
941+
942+
let tmpdir = tempfile::tempdir().unwrap();
943+
let file_path = tmpdir.path().join("testfile");
944+
let symlink_path = tmpdir.path().join("symlink");
945+
946+
fs::write(&file_path, b"test").unwrap();
947+
948+
symlink_file(&file_path, &symlink_path).expect("failed to create symlink");
949+
950+
assert!(symlink_path.exists());
951+
952+
assert!(remove_file(symlink_path.clone()).is_ok());
953+
954+
assert!(!symlink_path.exists());
955+
assert!(file_path.exists());
956+
}
934957
}

0 commit comments

Comments
 (0)