From 9a04e50a88c48585e2935764d5c1d7412fe54b4c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 28 May 2021 19:34:49 -0500 Subject: [PATCH] test: Verify CLI --- tests/cli.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/cli.rs diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 0000000..c65b771 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,24 @@ +use assert_cmd::Command; + +#[test] +fn test_stdin_success() { + let mut cmd = Command::cargo_bin("typos").unwrap(); + cmd.arg("-").write_stdin("Hello world"); + cmd.assert().success(); +} + +#[test] +fn test_stdin_failure() { + let mut cmd = Command::cargo_bin("typos").unwrap(); + cmd.arg("-").write_stdin("Apropriate world"); + cmd.assert().code(2); +} + +#[test] +fn test_stdin_correct() { + let mut cmd = Command::cargo_bin("typos").unwrap(); + cmd.arg("-") + .arg("--write-changes") + .write_stdin("Apropriate world"); + cmd.assert().success().stdout("Appropriate world"); +}