mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
Fixed tests.
This commit is contained in:
parent
4846175638
commit
2435b9d90c
@ -1,5 +1,7 @@
|
|||||||
# rustop
|
# rustop
|
||||||
|
|
||||||
|
[](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)
|
A top clone, written in Rust. Inspired by both [gtop](https://github.com/aksakalli/gtop) and [gotop](https://github.com/cjbassi/gotop)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -31,5 +33,3 @@ Currently, I'm unable to test on MacOS, so I'm not sure how well this will work,
|
|||||||
## Why
|
## Why
|
||||||
|
|
||||||
I was looking to try writing more things in Rust, and I love the gotop tool. And thus, this project was born.
|
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.
|
|
||||||
|
43
tests/arg_rate_tests.rs
Normal file
43
tests/arg_rate_tests.rs
Normal file
@ -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(())
|
||||||
|
}
|
@ -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(())
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user