Skip to content

Commit

Permalink
test(ignore_errors): Add help & version cmd tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiantoh committed Jun 28, 2023
1 parent 1f71fd9 commit d451e0a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/builder/ignore_errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use clap::{arg, Arg, ArgAction, Command};

use super::utils;

#[test]
fn single_short_arg_without_value() {
let cmd = Command::new("cmd").ignore_errors(true).arg(arg!(
Expand Down Expand Up @@ -124,3 +126,26 @@ fn subcommand() {
Some("some other val")
);
}

#[test]
#[should_panic(expected = "`Result::unwrap_err()` on an `Ok` value")]
fn help_command() {
static HELP: &str = "\
Usage: test
Options:
-h, --help Print help
";

let cmd = Command::new("test").ignore_errors(true);

utils::assert_output(cmd, "test --help", HELP, false);
}

#[test]
#[should_panic(expected = "`Result::unwrap_err()` on an `Ok` value")]
fn version_command() {
let cmd = Command::new("test").ignore_errors(true).version("0.1");

utils::assert_output(cmd, "test --version", "test 0.1\n", false);
}

0 comments on commit d451e0a

Please sign in to comment.