Files
vamp/tests/unit/cli_args.rs
T
2026-10-16 18:53:02 +02:00

47 lines
1.3 KiB
Rust

use super::*;
fn parse(args: &[&str]) -> Result<Option<Options>, String> {
parse_options(args.iter().map(std::ffi::OsString::from))
}
#[test]
fn review_commands_preserve_filenames_and_validate_arguments() {
assert_eq!(
parse(&["review"]).unwrap().unwrap().file,
Some("review".into())
);
assert_eq!(
parse(&["--", "--review"]).unwrap().unwrap().file,
Some("--review".into())
);
assert!(
parse(&["--no-config", "--review", "list", "--repo", ".", "--json"])
.unwrap()
.unwrap()
.review
.is_some()
);
assert!(
parse(&["--review", "show", "1", "--all", "--no-config"])
.unwrap()
.unwrap()
.review
.is_some()
);
for args in [
vec!["--review"],
vec!["--review", "show"],
vec!["--review", "show", "0"],
vec!["--review", "show", "-1"],
vec!["--review", "show", "abc"],
vec!["--review", "list", "--all"],
vec!["--review", "list", "--repo"],
vec!["--review", "list", "--repo", ".", "--repo", "."],
vec!["--review", "list", "extra"],
vec!["--review", "list", "--", "extra"],
vec!["--review", "list", "--config", "x", "--no-config"],
] {
assert!(parse(&args).is_err(), "{args:?}");
}
}