mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-10 14:44:18 +00:00
refactor: update arg tests to use new binary env
This commit is contained in:
parent
481275f61d
commit
4d512afdae
1 changed files with 14 additions and 25 deletions
|
@ -1,29 +1,18 @@
|
|||
use std::process::Command;
|
||||
|
||||
use assert_cmd::prelude::*;
|
||||
use predicates::prelude::*;
|
||||
use std::process::Command;
|
||||
|
||||
// These tests are mostly here just to ensure that invalid results will be caught when passing arguments...
|
||||
|
||||
// TODO: [TEST] Allow for release testing. Do this with paths.
|
||||
|
||||
//======================RATES======================//
|
||||
|
||||
fn get_os_binary_loc() -> String {
|
||||
if cfg!(target_os = "linux") {
|
||||
"./target/x86_64-unknown-linux-gnu/debug/btm".to_string()
|
||||
} else if cfg!(target_os = "windows") {
|
||||
"./target/x86_64-pc-windows-msvc/debug/btm".to_string()
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"./target/x86_64-apple-darwin/debug/btm".to_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
fn get_binary_location() -> String {
|
||||
env!("CARGO_BIN_EXE_btm").to_string()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_small_rate() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-r")
|
||||
.arg("249")
|
||||
.assert()
|
||||
|
@ -36,7 +25,7 @@ fn test_small_rate() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_large_default_time() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-t")
|
||||
.arg("18446744073709551616")
|
||||
.assert()
|
||||
|
@ -49,7 +38,7 @@ fn test_large_default_time() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_small_default_time() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-t")
|
||||
.arg("900")
|
||||
.assert()
|
||||
|
@ -62,7 +51,7 @@ fn test_small_default_time() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_large_delta_time() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-d")
|
||||
.arg("18446744073709551616")
|
||||
.assert()
|
||||
|
@ -75,7 +64,7 @@ fn test_large_delta_time() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_small_delta_time() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-d")
|
||||
.arg("900")
|
||||
.assert()
|
||||
|
@ -88,7 +77,7 @@ fn test_small_delta_time() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_large_rate() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-r")
|
||||
.arg("18446744073709551616")
|
||||
.assert()
|
||||
|
@ -102,7 +91,7 @@ fn test_large_rate() -> Result<(), Box<dyn std::error::Error>> {
|
|||
#[test]
|
||||
fn test_negative_rate() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// This test should auto fail due to how clap works
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-r")
|
||||
.arg("-1000")
|
||||
.assert()
|
||||
|
@ -116,7 +105,7 @@ fn test_negative_rate() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_invalid_rate() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-r")
|
||||
.arg("100-1000")
|
||||
.assert()
|
||||
|
@ -128,7 +117,7 @@ fn test_invalid_rate() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_conflicting_temps() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("-c")
|
||||
.arg("-f")
|
||||
.assert()
|
||||
|
@ -142,7 +131,7 @@ fn test_conflicting_temps() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_invalid_default_widget_1() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("--default_widget_type")
|
||||
.arg("fake_widget")
|
||||
.assert()
|
||||
|
@ -154,7 +143,7 @@ fn test_invalid_default_widget_1() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_invalid_default_widget_2() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Command::new(get_os_binary_loc())
|
||||
Command::new(get_binary_location())
|
||||
.arg("--default_widget_type")
|
||||
.arg("cpu")
|
||||
.arg("--default_widget_count")
|
||||
|
|
Loading…
Reference in a new issue