Skip to content

Commit

Permalink
test(cli): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjani committed Jan 19, 2021
1 parent 54b70df commit eddbfa0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
18 changes: 6 additions & 12 deletions src/gooseberry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ impl Gooseberry {
spinner.finish_with_message("Done!");
if added > 0 {
if added == 1 {
println!("Added 1 note");
println!("Added 1 annotation");
} else {
println!("Added {} notes", added);
println!("Added {} annotations", added);
}
}
if updated > 0 {
if updated == 1 {
println!("Updated 1 note");
println!("Updated 1 annotation");
} else {
println!("Updated {} notes", updated);
println!("Updated {} annotations", updated);
}
}
if added == 0 && updated == 0 {
Expand Down Expand Up @@ -289,10 +289,7 @@ impl Gooseberry {
if !annotations.is_empty()
&& (force
|| Confirm::new()
.with_prompt(&format!(
"Delete {} notes from gooseberry?",
num_annotations
))
.with_prompt(&format!("Delete {} annotations?", num_annotations))
.default(false)
.interact()?)
{
Expand All @@ -302,10 +299,7 @@ impl Gooseberry {
.collect::<Vec<_>>();
self.delete_annotations(&ids)?;
self.api.delete_annotations(&ids).await?;
println!(
"{} notes deleted from gooseberry and Hypothesis",
num_annotations
);
println!("{} annotations deleted", num_annotations);
}
Ok(())
}
Expand Down
9 changes: 4 additions & 5 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ impl TestData {
cmd.env("GOOSEBERRY_CONFIG", &self.config_file)
.arg("delete")
.arg("--tags=test_tag")
.arg("-a") // also from hypothesis
.arg("-f")
.assert()
.success();
Expand Down Expand Up @@ -163,7 +162,7 @@ async fn sync() -> color_eyre::Result<()> {
cmd.env("GOOSEBERRY_CONFIG", &test_data.config_file)
.arg("sync")
.assert()
.stdout(predicates::str::contains("Added 2 notes\n"));
.stdout(predicates::str::contains("Added 2 annotations\n"));

// update annotation
test_data.annotations[0].text = "Updated test annotation".into();
Expand All @@ -178,7 +177,7 @@ async fn sync() -> color_eyre::Result<()> {
cmd.env("GOOSEBERRY_CONFIG", &test_data.config_file)
.arg("sync")
.assert()
.stdout(predicates::str::contains("Updated 1 note"));
.stdout(predicates::str::contains("Updated 1 annotation"));

// clear
test_data.clear().await?;
Expand All @@ -199,7 +198,7 @@ async fn tag() -> color_eyre::Result<()> {
cmd.env("GOOSEBERRY_CONFIG", &test_data.config_file)
.arg("sync")
.assert()
.stdout(predicates::str::contains("Added 2 notes"));
.stdout(predicates::str::contains("Added 2 annotations"));

// add a tag
thread::sleep(duration);
Expand Down Expand Up @@ -284,7 +283,7 @@ async fn make() -> color_eyre::Result<()> {
cmd.env("GOOSEBERRY_CONFIG", &test_data.config_file)
.arg("sync")
.assert()
.stdout(predicates::str::contains("Added 2 notes"));
.stdout(predicates::str::contains("Added 2 annotations"));

// add a tag with spaces
thread::sleep(duration);
Expand Down

0 comments on commit eddbfa0

Please sign in to comment.