mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
refactor(mv): move to clap (#1652)
This commit is contained in:
parent
3ca8ba997c
commit
516839e081
4 changed files with 221 additions and 131 deletions
|
@ -17,6 +17,16 @@ fn test_mv_rename_dir() {
|
|||
assert!(at.dir_exists(dir2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_fail() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let dir1 = "test_mv_rename_dir";
|
||||
|
||||
at.mkdir(dir1);
|
||||
|
||||
ucmd.arg(dir1).fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_rename_file() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -301,6 +311,63 @@ fn test_mv_backup_numbering() {
|
|||
assert!(at.file_exists(&format!("{}.~1~", file_b)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_backup_existing() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let file_a = "test_mv_backup_numbering_file_a";
|
||||
let file_b = "test_mv_backup_numbering_file_b";
|
||||
|
||||
at.touch(file_a);
|
||||
at.touch(file_b);
|
||||
ucmd.arg("--backup=existing")
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_backup_simple() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let file_a = "test_mv_backup_numbering_file_a";
|
||||
let file_b = "test_mv_backup_numbering_file_b";
|
||||
|
||||
at.touch(file_a);
|
||||
at.touch(file_b);
|
||||
ucmd.arg("--backup=simple")
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_backup_none() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let file_a = "test_mv_backup_numbering_file_a";
|
||||
let file_b = "test_mv_backup_numbering_file_b";
|
||||
|
||||
at.touch(file_a);
|
||||
at.touch(file_b);
|
||||
ucmd.arg("--backup=none")
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(!at.file_exists(&format!("{}~", file_b)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_existing_backup() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -459,17 +526,15 @@ fn test_mv_errors() {
|
|||
|
||||
// $ mv -T -t a b
|
||||
// mv: cannot combine --target-directory (-t) and --no-target-directory (-T)
|
||||
scene
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg("-T")
|
||||
.arg("-t")
|
||||
.arg(dir)
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.fails()
|
||||
.stderr_is(
|
||||
"mv: error: cannot combine --target-directory (-t) and --no-target-directory (-T)\n",
|
||||
);
|
||||
.fails();
|
||||
assert!(result.stderr.contains("cannot be used with"));
|
||||
|
||||
// $ at.touch file && at.mkdir dir
|
||||
// $ mv -T file dir
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue