summaryrefslogtreecommitdiff
path: root/rust/echor/tests/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/echor/tests/cli.rs')
-rw-r--r--rust/echor/tests/cli.rs27
1 files changed, 27 insertions, 0 deletions
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);
+}