carman/tests/integration.rs

28 lines
903 B
Rust
Raw Normal View History

2022-05-06 02:29:22 +00:00
// filename: tests/integration.rs
mod integration {
2022-05-06 07:13:01 +00:00
use regex::Regex;
2022-05-06 02:29:22 +00:00
use std::process::Command;
#[test]
2022-05-06 07:13:01 +00:00
fn calling_carman_without_args_returns_result() {
let output = Command::new("./target/debug/carman")
2022-05-06 02:29:22 +00:00
.output()
.expect("failed to execute process");
2022-05-06 07:13:01 +00:00
let re = Regex::new(r"^Hello").unwrap();
assert!(re.is_match(&String::from_utf8_lossy(&output.stdout)));
}
#[test]
fn calling_carman_with_help_returns_usage() {
let output = Command::new("./target/debug/carman")
2022-05-06 07:13:01 +00:00
.arg("--help")
.output()
.expect("failed to execute process");
let re = Regex::new(r"^carman").unwrap();
assert!(re.is_match(&String::from_utf8_lossy(&output.stdout)));
let re = Regex::new(r"--help").unwrap();
assert!(re.is_match(&String::from_utf8_lossy(&output.stdout)));
2022-05-06 02:29:22 +00:00
}
}