From f5d86836655dc8cbb47f88b52fb8ad6f49572b05 Mon Sep 17 00:00:00 2001 From: Helio Frota <00hf11@gmail.com> Date: Thu, 7 Mar 2024 10:08:33 -0300 Subject: [PATCH] test: tests trustify-cli help * Adds pretty_assertions as dev-dependency for easy cli-diff-tests-results visualization --- backend/cli/Cargo.toml | 5 ++++- backend/cli/tests/cli.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 backend/cli/tests/cli.rs diff --git a/backend/cli/Cargo.toml b/backend/cli/Cargo.toml index bab49d22..a8b62b71 100644 --- a/backend/cli/Cargo.toml +++ b/backend/cli/Cargo.toml @@ -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"] } \ No newline at end of file +tokio = { version = "1", features = ["full"] } + +[dev-dependencies] +pretty_assertions = "1.4.0" \ No newline at end of file diff --git a/backend/cli/tests/cli.rs b/backend/cli/tests/cli.rs new file mode 100644 index 00000000..803918bb --- /dev/null +++ b/backend/cli/tests/cli.rs @@ -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 + +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); +}