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;
|
2022-05-06 07:13:01 +00:00
|
|
|
use std::process::Output;
|
2022-05-06 02:29:22 +00:00
|
|
|
|
|
|
|
static WITHOUT_ARGS_OUTPUT: &'static str = " USAGE:
|
|
|
|
carman [FLAGS] [OPTIONS] <URL>
|
|
|
|
For more information try --help
|
|
|
|
";
|
|
|
|
|
|
|
|
#[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")
|
|
|
|
.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
|
|
|
}
|
|
|
|
|
|
|
|
}
|