Skip to content

Commit

Permalink
Merge pull request #251 from simongdavies/fix-message
Browse files Browse the repository at this point in the history
custom message if no bindles
  • Loading branch information
simongdavies authored Oct 6, 2021
2 parents 3db7e11 + 0096452 commit 0b0f660
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
20 changes: 12 additions & 8 deletions bin/client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,16 @@ fn tablify(matches: &bindle::search::Matches) {
.unwrap_or_else(|| "[no description available]".to_string())
)
}
println!(
"=== Showing results {} to {} of {} (limit: {}){}",
matches.offset + 1,
last,
matches.total,
matches.limit,
trailer,
);
if matches.total > 0 {
println!(
"=== Showing results {} to {} of {} (limit: {}){}",
matches.offset + 1,
last,
matches.total,
matches.limit,
trailer,
);
} else {
println!("No matching bindles were found");
}
}
28 changes: 28 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,34 @@ async fn test_yank() {
assert_status(output, "Should be able to yank a bindle");
}

#[tokio::test]
async fn test_no_bindles() {
let controller = TestController::new(BINARY_NAME).await;
let output = std::process::Command::new("cargo")
.args(&[
"run",
"--features",
"cli",
"--bin",
"bindle",
"--",
"search",
])
.env(ENV_BINDLE_URL, &controller.base_url)
.output()
.expect("Should be able to run command");
assert!(
output.status.success(),
"Should be able to search for bindles"
);
assert!(
String::from_utf8_lossy(&output.stdout)
.trim_end()
.ends_with("No matching bindles were found"),
"Should get no bindles found message"
);
}

fn assert_status(output: std::process::Output, message: &str) {
assert!(
output.status.success(),
Expand Down

0 comments on commit 0b0f660

Please sign in to comment.