summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-07-03 21:54:21 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-07-03 21:54:21 +0200
commite18a928db5916fce43c35dff585072dace0da7e0 (patch)
treed33c8d6c08a779b0f28ddff83ce540b3821160e4 /tests
parentff05e4ab91b3b84ffb04b3d8089052112e7bd51c (diff)
Added a new "--verbose" option to the list command
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs64
1 files changed, 46 insertions, 18 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 12e701f..dbe99b2 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -254,7 +254,7 @@ fn allows_single_quotes_and_spaces_inside_double_quotes() -> Result<()> {
const DEFAULT_DESCRIPTION: &str =
"Unnamed repository; edit this file 'description' to name the repository.";
-fn expect_list_table(c: &mut TestContext, repos: &[(String, String)]) -> Result<()> {
+fn expect_list_table(c: &mut TestContext, repos: &[(&str, &str)]) -> Result<()> {
c.p.send_line("list")?;
c.p.exp_regex(r"\+-+\+-+\+")?;
c.p.exp_regex(r"\| path +\| description +\|")?;
@@ -271,6 +271,25 @@ fn expect_list_table(c: &mut TestContext, repos: &[(String, String)]) -> Result<
Ok(())
}
+fn expect_list_table_verbose(c: &mut TestContext, repos: &[(&str, &str)]) -> Result<()> {
+ c.p.send_line("list --verbose")?;
+ c.p.exp_regex(r"\+-+\+-+\+-+\+")?;
+ c.p.exp_regex(r"\| path +\| description +\| size +\|")?;
+ c.p.exp_regex(r"\+=+\+")?;
+ for (path, description) in repos {
+ c.p.exp_string("| ")?;
+ c.p.exp_string(path)?;
+ c.p.exp_regex(r" +\| ")?;
+ c.p.exp_string(&description)?;
+ c.p.exp_regex(r" +\|")?;
+ c.p.exp_regex(r"\d+ (MiB|KiB|B)")?;
+ c.p.exp_regex(r" +\|")?;
+ }
+ c.p.exp_regex(r"\+-+\+-+\+-+\+")?;
+ c.expect_prompt()?;
+ Ok(())
+}
+
#[test]
fn list_can_print_an_empty_list() -> Result<()> {
let mut c = spawn_interactive_process()?;
@@ -287,10 +306,7 @@ fn list_can_print_a_list_of_personal_repos_with_descriptions() -> Result<()> {
expect_list_table(
&mut c,
- &[(
- personal_repo_path(REPO_NAME),
- DEFAULT_DESCRIPTION.to_owned(),
- )],
+ &[(&personal_repo_path(REPO_NAME), DEFAULT_DESCRIPTION)],
)?;
Ok(())
@@ -309,14 +325,29 @@ fn list_can_print_a_list_of_all_repos_with_descriptions() -> Result<()> {
expect_list_table(
&mut c,
&[
- (
- personal_repo_path(REPO_NAME),
- DEFAULT_DESCRIPTION.to_owned(),
- ),
- (
- group_repo_path(&group, REPO_NAME_2),
- DEFAULT_DESCRIPTION.to_owned(),
- ),
+ (&personal_repo_path(REPO_NAME), DEFAULT_DESCRIPTION),
+ (&group_repo_path(&group, REPO_NAME_2), DEFAULT_DESCRIPTION),
+ ],
+ )?;
+
+ Ok(())
+}
+
+#[test]
+fn list_can_print_a_verbose_list_of_all_repos() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ c.p.send_line(&format!("init {}", REPO_NAME))?;
+ c.expect_successful_init_message(&personal_repo_path(REPO_NAME))?;
+
+ let group = arbitrary_user_group();
+ c.p.send_line(&format!("init --group {} {}", group, REPO_NAME_2))?;
+ c.expect_successful_init_message(&group_repo_path(&group, REPO_NAME_2))?;
+
+ expect_list_table_verbose(
+ &mut c,
+ &[
+ (&personal_repo_path(REPO_NAME), DEFAULT_DESCRIPTION),
+ (&group_repo_path(&group, REPO_NAME_2), DEFAULT_DESCRIPTION),
],
)?;
@@ -330,10 +361,7 @@ fn can_set_the_description_on_a_repo_during_init() -> Result<()> {
c.p.send_line(&format!("init --description \"{description}\" {REPO_NAME}"))?;
c.expect_successful_init_message(&personal_repo_path(REPO_NAME))?;
- expect_list_table(
- &mut c,
- &[(personal_repo_path(REPO_NAME), description.to_owned())],
- )?;
+ expect_list_table(&mut c, &[(&personal_repo_path(REPO_NAME), description)])?;
Ok(())
}
@@ -350,7 +378,7 @@ fn can_change_the_description_on_a_repo() -> Result<()> {
))?;
c.p.exp_string("Successfully updated description")?;
c.expect_prompt()?;
- expect_list_table(&mut c, &[(repo_path, description.to_owned())])?;
+ expect_list_table(&mut c, &[(&repo_path, description)])?;
Ok(())
}