From da8802d1fb0c5707877777ff4187238195eef16b Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Sat, 24 Jun 2023 21:52:37 +0200 Subject: Added a command to delete a repo --- tests/cli.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/cli.rs b/tests/cli.rs index 41fe145..7bda913 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -98,6 +98,10 @@ fn verify_repo_exists(repo_dir: &Path) { .stdout(""); } +fn verify_repo_does_not_exist(repo_dir: &Path) { + assert!(!repo_dir.exists()); +} + fn verify_current_branch(repo_dir: &Path, expected_ref: &str) { Command::new("git") .arg("symbolic-ref") @@ -423,3 +427,28 @@ fn can_change_the_main_branch_on_a_repo() -> Result<()> { Ok(()) } + +#[test] +fn can_delete_a_repo() -> Result<()> { + let mut c = spawn_interactive_process()?; + let username = get_username().unwrap(); + let repo_name = "an-old-repo"; + let repo_path = format!("git/{username}/{repo_name}.git"); + let repo_dir = c + .workdir + .as_ref() + .join("git") + .join(username) + .join(&format!("{}.git", repo_name)); + + c.p.send_line(&format!("init {}", repo_name))?; + c.p.exp_string(&format!("Successfully created \"{repo_path}\""))?; + verify_repo_exists(&repo_dir); + + c.p.send_line(&format!("delete \"{repo_path}\""))?; + c.p.exp_string(&format!("Successfully deleted \"{repo_path}\""))?; + + verify_repo_does_not_exist(&repo_dir); + + Ok(()) +} -- cgit v1.2.3