summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-04-04 21:03:46 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-04-04 21:03:46 +0200
commit7475e89080d292cf995f805b3ca3e6dca11b8810 (patch)
tree9c96a4d6af759de0a9a6ee7bc0e2877a7e861460
parentbb0ab2b2c200bd49c3fdf66e23184d4627067aca (diff)
Figure out the testing for listing
Needs regexes to accomodate the different table sizes
-rw-r--r--tests/cli.rs38
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 648b6c1..e64ce6b 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -140,7 +140,7 @@ fn can_init_a_new_git_repo() -> Result<()> {
#[test]
fn can_init_a_new_shared_git_repo() -> Result<()> {
let mut c = spawn_interactive_process()?;
- let group = get_user_groups().pop().unwrap();
+ let group = get_user_groups().into_iter().next().unwrap();
let repo_name = "my-new-shared-repo";
c.p.send_line(&format!("git-init --group {} {}", group, repo_name))?;
c.p.exp_string(&format!(
@@ -239,23 +239,41 @@ fn list_can_print_an_empty_list() -> Result<()> {
}
#[test]
-fn list_can_print_an_list_of_all_repos_with_descriptions() -> Result<()> {
+fn list_can_print_a_list_of_personal_repos_with_descriptions() -> Result<()> {
let mut c = spawn_interactive_process()?;
+ let user = get_username().unwrap();
let personal_repo_name = "my-personal-repo";
c.p.send_line(&format!("git-init {}", personal_repo_name))?;
- let group = get_user_groups().pop().unwrap();
+ c.p.send_line("list")?;
+ c.p.exp_regex(r"\+-+\+-+\+")?;
+ c.p.exp_regex(r"\| path +\| description +\|")?;
+ c.p.exp_regex(r"\+=+\+")?;
+ c.p.exp_regex(&format!(r"\| git/{user}/{personal_repo_name}\.git +\| Unnamed repository; edit this file 'description' to name the repository\. +\|"))?;
+ c.p.exp_regex(r"\+-+\+-+\+")?;
+ expect_prompt(&mut c.p)?;
+
+ Ok(())
+}
+
+#[test]
+fn list_can_print_a_list_of_all_repos_with_descriptions() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ let user = get_username().unwrap();
+ let personal_repo_name = "my-personal-repo";
+ c.p.send_line(&format!("git-init {}", personal_repo_name))?;
+
+ let group = get_user_groups().into_iter().next().unwrap();
let shared_repo_name = "my-shared-repo";
c.p.send_line(&format!("git-init --group {} {}", group, shared_repo_name))?;
c.p.send_line("list")?;
- c.p.exp_string("+------+-------------+")?;
- c.p.exp_string("| path | description |")?;
- c.p.exp_string("+====================+")?;
- c.p.exp_string("| git/shukkie/my-personal-repo | |+")?;
- c.p.exp_string(&format!("| git/{group}/{shared_repo_name} | |+"))?;
- c.p.exp_string("+------+-------------+")?;
- expect_prompt(&mut c.p)?;
+ c.p.exp_regex(r"\+-+\+-+\+")?;
+ c.p.exp_regex(r"| path +| description +|")?;
+ c.p.exp_regex(r"\+=+\+")?;
+ c.p.exp_regex(&format!(r"\| git/{user}/{personal_repo_name}\.git +\| Unnamed repository; edit this file 'description' to name the repository\. +\|"))?;
+ c.p.exp_regex(&format!(r"\| git/{group}/{shared_repo_name}\.git +\| Unnamed repository; edit this file 'description' to name the repository\. +\|"))?;
+ c.p.exp_regex(r"\+-+\+-+\+")?;
Ok(())
}