summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-08-18 14:02:43 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-08-18 14:04:22 +0200
commit5594c1454d9b57418273b4b6fa009529482cc77d (patch)
treee4a37b6bec92eda21cab3f26f2ed5ce054457e07 /tests
parentcca27c355823272ccc5927057d5fe228ede0bd41 (diff)
Added a prompt to confirm risky actions like deleting a repo
Fix #3
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 34249c2..633c7bd 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -284,6 +284,11 @@ 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);
@@ -291,6 +296,28 @@ fn can_delete_a_repo() -> Result<()> {
}
#[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()?;
let repo_path = personal_repo_path(REPO_NAME);