2021-05-28 20:34:49 -04:00
|
|
|
use assert_cmd::Command;
|
|
|
|
|
|
|
|
#[test]
|
2021-07-01 20:33:32 -04:00
|
|
|
#[cfg(feature = "dict")]
|
2021-05-28 20:34:49 -04:00
|
|
|
fn test_stdin_success() {
|
|
|
|
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
|
|
cmd.arg("-").write_stdin("Hello world");
|
|
|
|
cmd.assert().success();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-01 20:33:32 -04:00
|
|
|
#[cfg(feature = "dict")]
|
2021-05-28 20:34:49 -04:00
|
|
|
fn test_stdin_failure() {
|
|
|
|
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
|
|
cmd.arg("-").write_stdin("Apropriate world");
|
|
|
|
cmd.assert().code(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-01 20:33:32 -04:00
|
|
|
#[cfg(feature = "dict")]
|
2021-05-28 20:34:49 -04:00
|
|
|
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");
|
|
|
|
}
|
2021-06-05 14:46:40 -04:00
|
|
|
|
|
|
|
#[test]
|
2021-07-01 20:33:32 -04:00
|
|
|
#[cfg(feature = "dict")]
|
2021-06-05 14:46:40 -04:00
|
|
|
fn test_file_failure() {
|
|
|
|
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
|
|
cmd.arg("README.md");
|
|
|
|
cmd.assert().code(2);
|
|
|
|
}
|
2021-06-07 07:28:53 -04:00
|
|
|
|
|
|
|
#[test]
|
2021-07-01 20:33:32 -04:00
|
|
|
#[cfg(feature = "dict")]
|
2021-06-07 07:28:53 -04:00
|
|
|
fn test_relative_dir_failure() {
|
|
|
|
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
|
|
cmd.arg(".");
|
|
|
|
cmd.assert().code(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-01 20:33:32 -04:00
|
|
|
#[cfg(feature = "dict")]
|
2021-06-07 07:28:53 -04:00
|
|
|
fn test_assumed_dir_failure() {
|
|
|
|
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
|
|
cmd.assert().code(2);
|
|
|
|
}
|