diff options
author | ClementTsang <clementjhtsang@gmail.com> | 2019-09-14 22:29:40 -0400 |
---|---|---|
committer | ClementTsang <clementjhtsang@gmail.com> | 2019-09-14 22:29:40 -0400 |
commit | 2435b9d90ce8029dd731238972f3610a56b6c3f9 (patch) | |
tree | 9f27f81712e66a42a90059cf6b36ef2b15ecc65a /tests | |
parent | 48461756380e11533173eb1688e97203575687dd (diff) |
Fixed tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arg_rate_tests.rs | 43 | ||||
-rw-r--r-- | tests/arg_tests.rs | 40 |
2 files changed, 43 insertions, 40 deletions
diff --git a/tests/arg_rate_tests.rs b/tests/arg_rate_tests.rs new file mode 100644 index 00000000..f4c14687 --- /dev/null +++ b/tests/arg_rate_tests.rs @@ -0,0 +1,43 @@ +use assert_cmd::prelude::*; // Add methods on commands +use predicates::prelude::*; +use std::process::Command; // Run programs // Used for writing assertions + +#[test] +fn valid_rate_argument() { +} + +#[test] +fn test_small_rate() -> Result<(), Box<dyn std::error::Error>> { + Command::new("./target/debug/rustop") + .arg("-r") + .arg("249") + .assert() + .failure() + .stderr(predicate::str::contains("rate to be greater than 250")); + Ok(()) +} + +#[test] +fn test_negative_rate() -> Result<(), Box<dyn std::error::Error>> { + // This test should auto fail due to how clap works + Command::new("./target/debug/rustop") + .arg("-r") + .arg("-1000") + .assert() + .failure() + .stderr(predicate::str::contains("wasn't expected, or isn't valid in this context")); + + Ok(()) +} + +#[test] +fn test_invalid_rate() -> Result<(), Box<dyn std::error::Error>> { + Command::new("./target/debug/rustop") + .arg("-r") + .arg("100-1000") + .assert() + .failure() + .stderr(predicate::str::contains("invalid digit")); + + Ok(()) +} diff --git a/tests/arg_tests.rs b/tests/arg_tests.rs deleted file mode 100644 index 978b24c6..00000000 --- a/tests/arg_tests.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::process::Command; // Run programs -use assert_cmd::prelude::*; // Add methods on commands -use predicates::prelude::*; // Used for writing assertions - -#[test] -fn test_small_rate -> Result<(), Box<std::error::Error>> { - let mut cmd = Command::main_binary()?; - cmd.arg("-r") - .arg("249"); - cmd.assert() - .failure() - .stderr(predicate::str::contains("rate")); - - Ok(()) -} - -#[test] -fn test_negative_rate -> Result<(), Box<std::error::Error>> { - // This test should auto fail due to how clap works - let mut cmd = Command::main_binary()?; - cmd.arg("-r") - .arg("-1000"); - cmd.assert() - .failure() - .stderr(predicate::str::contains("valid")); - - Ok(()) -} - -#[test] -fn test_invalid_rate -> Result<(), Box<std::error::Error>> { - let mut cmd = Command::main_binary()?; - cmd.arg("-r") - .arg("1000 - 100"); - cmd.assert() - .failure() - .stderr(predicate::str::contains("digit")); - - Ok(()) -}
\ No newline at end of file |