Skip to content

Commit 8b0161e

Browse files
committed
test: add a test case for removing symlink dir
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 84dc5dc commit 8b0161e

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
@@ -908,4 +908,27 @@ mod tests {
908908
);
909909
}
910910
}
911+
912+
#[test]
913+
#[cfg(windows)]
914+
fn test_remove_symlink_dir() {
915+
use super::*;
916+
use std::fs;
917+
use std::os::windows::fs::symlink_dir;
918+
919+
let tmpdir = tempfile::tempdir().unwrap();
920+
let dir_path = tmpdir.path().join("testdir");
921+
let symlink_path = tmpdir.path().join("symlink");
922+
923+
fs::create_dir(&dir_path).unwrap();
924+
925+
symlink_dir(&dir_path, &symlink_path).expect("failed to create symlink");
926+
927+
assert!(symlink_path.exists());
928+
929+
assert!(remove_file(symlink_path.clone()).is_err());
930+
931+
assert!(symlink_path.exists());
932+
assert!(dir_path.exists());
933+
}
911934
}

0 commit comments

Comments
 (0)