use existing fixture file instead of new ones

This commit is contained in:
Phil Gebhardt 2022-06-18 09:51:39 -07:00
parent c49d8e6113
commit 30f03b3ded
No known key found for this signature in database
GPG key ID: 0CB299805A6F020F

View file

@ -38,8 +38,6 @@ static TEST_COPY_FROM_FOLDER: &str = "hello_dir_with_file/";
static TEST_COPY_FROM_FOLDER_FILE: &str = "hello_dir_with_file/hello_world.txt";
static TEST_COPY_TO_FOLDER_NEW: &str = "hello_dir_new";
static TEST_COPY_TO_FOLDER_NEW_FILE: &str = "hello_dir_new/hello_world.txt";
static TEST_PROTECT_BACKUP_SRC: &str = "protected.txt.bak";
static TEST_PROTECT_BACKUP_DEST: &str = "protected.txt";
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
static TEST_MOUNT_COPY_FROM_FOLDER: &str = "dir_with_mount";
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
@ -563,20 +561,19 @@ fn test_cp_backup_simple() {
#[test]
fn test_cp_backup_simple_protect_source() {
let (at, mut ucmd) = at_and_ucmd!();
let source = format!("{}~", TEST_HELLO_WORLD_SOURCE);
at.touch(&source);
ucmd.arg("--backup=simple")
.arg("--suffix")
.arg(".bak")
.arg(TEST_PROTECT_BACKUP_SRC)
.arg(TEST_PROTECT_BACKUP_DEST)
.arg(&source)
.arg(TEST_HELLO_WORLD_SOURCE)
.fails()
.stderr_only(format!(
"cp: backing up '{}' might destroy source; '{}' not copied",
TEST_PROTECT_BACKUP_DEST,
TEST_PROTECT_BACKUP_SRC,
TEST_HELLO_WORLD_SOURCE, source,
));
assert_eq!(at.read(TEST_PROTECT_BACKUP_SRC), "original text\n");
assert_eq!(at.read(TEST_PROTECT_BACKUP_DEST), "new text\n");
assert_eq!(at.read(TEST_HELLO_WORLD_SOURCE), "Hello, World!\n");
assert_eq!(at.read(&source), "");
}
#[test]