From ee8a08bfa24d9a3d09273fdebe8d73ac38c545f9 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sat, 6 Sep 2025 09:30:39 +0200 Subject: Update guessing game Signed-off-by: Carlos Maiolino --- rust/echor/tests/cli.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 rust/echor/tests/cli.rs (limited to 'rust/echor/tests/cli.rs') diff --git a/rust/echor/tests/cli.rs b/rust/echor/tests/cli.rs new file mode 100644 index 0000000..e78eb36 --- /dev/null +++ b/rust/echor/tests/cli.rs @@ -0,0 +1,27 @@ +use assert_cmd::Command; +use predicates::prelude::*; +use std::fs; + +#[test] +fn dies_no_args() { + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.assert() + .failure() + .stderr(predicate::str::contains("USAGE")); +} + +#[test] +fn runs() { + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.arg("Howdy partner").assert().success(); +} + +#[test] +fn hello1() { + let expected = fs::read_to_string("tests/expected/hello1.txt").unwrap(); + let mut cmd = Command::cargo_bin("echor").unwrap(); + cmd.arg("Hello there") + .assert() + .success() + .stdout(expected); +} -- cgit v1.2.3