diff options
Diffstat (limited to 'rust/echor/tests')
| -rw-r--r-- | rust/echor/tests/.cli.rs.un~ | bin | 0 -> 10463 bytes | |||
| -rw-r--r-- | rust/echor/tests/cli.rs | 27 | ||||
| -rw-r--r-- | rust/echor/tests/cli.rs~ | 26 | ||||
| -rw-r--r-- | rust/echor/tests/expected/hello1.txt | 1 |
4 files changed, 54 insertions, 0 deletions
diff --git a/rust/echor/tests/.cli.rs.un~ b/rust/echor/tests/.cli.rs.un~ Binary files differnew file mode 100644 index 0000000..7a6e081 --- /dev/null +++ b/rust/echor/tests/.cli.rs.un~ 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); +} diff --git a/rust/echor/tests/cli.rs~ b/rust/echor/tests/cli.rs~ new file mode 100644 index 0000000..d6e32b1 --- /dev/null +++ b/rust/echor/tests/cli.rs~ @@ -0,0 +1,26 @@ +use assert_cmd::Command; +use predicates::prelude::*; + +#[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); +} diff --git a/rust/echor/tests/expected/hello1.txt b/rust/echor/tests/expected/hello1.txt new file mode 100644 index 0000000..d6613f5 --- /dev/null +++ b/rust/echor/tests/expected/hello1.txt @@ -0,0 +1 @@ +Hello there |
