diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2023-06-24 21:52:37 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2023-06-24 21:52:37 +0200 |
commit | da8802d1fb0c5707877777ff4187238195eef16b (patch) | |
tree | 60b6d9ca408d252c2f6e96b1c90a3993c3f0dc39 /tests | |
parent | 20ff259800f3a5568c53fca3992c4e062282b82a (diff) |
Added a command to delete a repo
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cli.rs | 29 |
1 files changed, 29 insertions, 0 deletions
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(()) +} |