refactor: move embedded tests into dedicated test directory
This commit is contained in:
+2
-48
@@ -254,51 +254,5 @@ fn main() {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
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:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#[path = "../tests/unit/cli_args.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user