Skip to content

Commit

Permalink
test: tests trustify-cli help
Browse files Browse the repository at this point in the history
* Adds pretty_assertions as dev-dependency for easy cli-diff-tests-results visualization
  • Loading branch information
helio-frota committed Mar 7, 2024
1 parent 46fd3a4 commit f5d8683
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ env_logger = "0.10.0"
log = "0.4.19"
serde_json = "1.0.104"
thiserror = "1"
tokio = { version = "1", features = ["full"] }
tokio = { version = "1", features = ["full"] }

[dev-dependencies]
pretty_assertions = "1.4.0"
28 changes: 28 additions & 0 deletions backend/cli/tests/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use pretty_assertions::assert_eq;
use std::env;
use tokio::process::Command;

const TRUSTIFY_CLI_HELP: &str = "huevos
Usage: trustify-cli <COMMAND>
Commands:
importer
server Run the API server
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
";

#[tokio::test]
async fn trustify_cli_help() {
let output = Command::new(env!("CARGO_BIN_EXE_trustify-cli"))
.output()
.await
.expect("");

let output_str = String::from_utf8_lossy(&output.stderr).to_string();
assert_eq!(TRUSTIFY_CLI_HELP, output_str);
}

0 comments on commit f5d8683

Please sign in to comment.