diff --git a/README.md b/README.md index 3fd755e8..3f837540 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # rustop +[![Build Status](https://travis-ci.com/ClementTsang/rustop.svg?token=1wvzVgp94E1TZyPNs8JF&branch=master)](https://travis-ci.com/ClementTsang/rustop) + A top clone, written in Rust. Inspired by both [gtop](https://github.com/aksakalli/gtop) and [gotop](https://github.com/cjbassi/gotop) ## Installation @@ -31,5 +33,3 @@ Currently, I'm unable to test on MacOS, so I'm not sure how well this will work, ## Why I was looking to try writing more things in Rust, and I love the gotop tool. And thus, this project was born. - -Also, yes, I realize that gotop has a Rust rewrite branch... I found out about that when I was nearly ready to release the first version. 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> { + 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> { + // 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> { + 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> { - 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> { - // 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> { - 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