rm: test prompts when --interactive is once

This commit is contained in:
John Shin 2023-05-22 21:27:43 -07:00
parent e50b84035f
commit 421b2f2581

View file

@ -381,6 +381,54 @@ fn test_rm_interactive_missing_value() {
assert!(!at.file_exists(file1)); assert!(!at.file_exists(file1));
assert!(!at.file_exists(file2)); assert!(!at.file_exists(file2));
} }
#[test]
fn test_rm_interactive_once_prompt() {
let (at, mut ucmd) = at_and_ucmd!();
let file1 = "test_rm_interactive_once_recursive_prompt_file1";
let file2 = "test_rm_interactive_once_recursive_prompt_file2";
let file3 = "test_rm_interactive_once_recursive_prompt_file3";
let file4 = "test_rm_interactive_once_recursive_prompt_file4";
at.touch(file1);
at.touch(file2);
at.touch(file3);
at.touch(file4);
ucmd.arg("--interactive=once")
.arg(file1)
.arg(file2)
.arg(file3)
.arg(file4)
.pipe_in("y")
.succeeds()
.stderr_contains("remove 4 arguments?");
assert!(!at.file_exists(file1));
assert!(!at.file_exists(file2));
assert!(!at.file_exists(file3));
assert!(!at.file_exists(file4));
}
#[test]
fn test_rm_interactive_once_recursive_prompt() {
let (at, mut ucmd) = at_and_ucmd!();
let file1 = "test_rm_interactive_once_recursive_prompt_file1";
at.touch(file1);
ucmd.arg("--interactive=once")
.arg("-r")
.arg(file1)
.pipe_in("y")
.succeeds()
.stderr_contains("remove 1 argument recursively?");
assert!(!at.file_exists(file1));
}
#[test] #[test]
fn test_rm_descend_directory() { fn test_rm_descend_directory() {
// This test descends into each directory and deletes the files and folders inside of them // This test descends into each directory and deletes the files and folders inside of them