enhance test case

Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
tommady 2025-07-17 08:52:14 +00:00
parent 3858076274
commit 13898bbef3
No known key found for this signature in database
GPG Key ID: 175B664929DF2F2F

View File

@ -685,7 +685,8 @@ fn symlink_pack_and_unpack(
let root_path = temp_dir.path(); let root_path = temp_dir.path();
let src_files_path = root_path.join("src_files"); let src_files_path = root_path.join("src_files");
fs::create_dir_all(&src_files_path)?; let folder_path = src_files_path.join("folder");
fs::create_dir_all(&folder_path)?;
let mut files_path = ["file1.txt", "file2.txt", "file3.txt", "file4.txt", "file5.txt"] let mut files_path = ["file1.txt", "file2.txt", "file3.txt", "file4.txt", "file5.txt"]
.into_iter() .into_iter()
@ -700,10 +701,15 @@ fn symlink_pack_and_unpack(
fs::create_dir_all(&dest_files_path)?; fs::create_dir_all(&dest_files_path)?;
let symlink_path = src_files_path.join(Path::new("symlink")); let symlink_path = src_files_path.join(Path::new("symlink"));
let symlink_folder_path = src_files_path.join(Path::new("symlink_folder"));
#[cfg(unix)] #[cfg(unix)]
std::os::unix::fs::symlink(&files_path[0], &symlink_path)?; std::os::unix::fs::symlink(&files_path[0], &symlink_path)?;
#[cfg(unix)]
std::os::unix::fs::symlink(&folder_path, &symlink_folder_path)?;
#[cfg(windows)] #[cfg(windows)]
std::os::windows::fs::symlink_file(&files_path[0], &symlink_path)?; std::os::windows::fs::symlink_file(&files_path[0], &symlink_path)?;
#[cfg(windows)]
std::os::windows::fs::symlink_dir(&folder_path, &symlink_folder_path)?;
files_path.push(symlink_path); files_path.push(symlink_path);
@ -728,7 +734,7 @@ fn symlink_pack_and_unpack(
// check the symlink stand still // check the symlink stand still
for f in dest_files_path.as_path().read_dir()? { for f in dest_files_path.as_path().read_dir()? {
let f = f?; let f = f?;
if f.file_name() == "symlink" { if f.file_name() == "symlink" || f.file_name() == "symlink_folder" {
assert!(f.file_type()?.is_symlink()) assert!(f.file_type()?.is_symlink())
} }
} }