Skip to content

Commit f595ae1

Browse files
authored
test(cp): cover symlink file download destination (#255)
1 parent 43e8d87 commit f595ae1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • crates/cli/src/commands

crates/cli/src/commands/cp.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,22 @@ mod tests {
11561156
assert!(result.is_err());
11571157
}
11581158

1159+
#[cfg(unix)]
1160+
#[tokio::test]
1161+
async fn download_destination_rejects_existing_symlink_file() {
1162+
use std::os::unix::fs::symlink;
1163+
1164+
let root = tempfile::tempdir().expect("create destination root");
1165+
let outside = tempfile::tempdir().expect("create outside directory");
1166+
let outside_file = outside.path().join("file.txt");
1167+
std::fs::write(&outside_file, b"outside").expect("write outside file");
1168+
symlink(&outside_file, root.path().join("file.txt")).expect("create test symlink");
1169+
1170+
let result = safe_download_destination(root.path(), &PathBuf::from("file.txt")).await;
1171+
1172+
assert!(result.is_err());
1173+
}
1174+
11591175
#[test]
11601176
fn test_select_upload_content_type_uses_guess_for_small_files() {
11611177
let selected =

0 commit comments

Comments
 (0)