From ad4eac867f4cd560ec8eee1d4beb409ab64e48a8 Mon Sep 17 00:00:00 2001 From: Stefin Date: Tue, 23 Aug 2022 21:17:48 +0530 Subject: [PATCH] rm: added test for rm_prompt_write_protected Signed-off-by: Stefin --- tests/by-util/test_rm.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index e765935768e..c752cc442f3 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -363,3 +363,33 @@ fn test_rm_directory_rights_rm1() { assert!(!at.dir_exists("b/c")); assert!(!at.dir_exists("b/d")); } + +#[test] +fn test_prompt_write_protected_yes() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let file_1 = "test_rm_prompt_write_protected_1"; + + at.touch(file_1); + + #[cfg(feature = "chmod")] + scene.ccmd("chmod").arg("0").arg(file_1).succeeds(); + + scene.ucmd().arg(file_1).pipe_in("y").succeeds(); + assert!(!at.file_exists(file_1)); +} + +#[test] +fn test_prompt_write_protected_no() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let file_2 = "test_rm_prompt_write_protected_2"; + + at.touch(file_2); + + #[cfg(feature = "chmod")] + scene.ccmd("chmod").arg("0").arg(file_2).succeeds(); + + scene.ucmd().arg(file_2).pipe_in("n").succeeds(); + assert!(at.file_exists(file_2)); +}