From 5594c1454d9b57418273b4b6fa009529482cc77d Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Fri, 18 Aug 2023 14:02:43 +0200 Subject: Added a prompt to confirm risky actions like deleting a repo Fix #3 --- tests/cli.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/cli.rs b/tests/cli.rs index 34249c2..633c7bd 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -284,12 +284,39 @@ fn can_delete_a_repo() -> Result<()> { verify_repo_exists(&repo_dir); c.p.send_line(&format!("delete \"{repo_path}\""))?; + c.p.exp_string(&format!( + "Are you sure you want to delete \"{repo_path}\"? (yes/no)" + ))?; + + c.p.send_line("yes")?; c.p.exp_string(&format!("Successfully deleted \"{repo_path}\""))?; verify_repo_does_not_exist(&repo_dir); Ok(()) } +#[test] +fn repo_is_not_deleted_if_you_say_youre_not_sure() -> Result<()> { + let mut c = TestContext::new_interactive()?; + let repo_path = personal_repo_path(REPO_NAME); + let repo_dir = c.personal_repo_dir(REPO_NAME); + + c.p.send_line(&format!("init {}", REPO_NAME))?; + c.expect_successful_init_message(&repo_path)?; + verify_repo_exists(&repo_dir); + + c.p.send_line(&format!("delete \"{repo_path}\""))?; + c.p.exp_string(&format!( + "Are you sure you want to delete \"{repo_path}\"? (yes/no)" + ))?; + + c.p.send_line("no")?; + c.p.exp_string(&format!("Action cancelled"))?; + verify_repo_exists(&repo_dir); + + Ok(()) +} + #[test] fn git_housekeeping_repacks_objects() -> Result<()> { let mut c = TestContext::new_interactive()?; -- cgit v1.2.3