feat: resolve review comments through the CLI
This commit is contained in:
@@ -105,3 +105,41 @@ fn existing_storage_is_read_only_and_unchanged() {
|
||||
}
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn comment_mutations_require_positive_explicit_ids_and_reject_all() {
|
||||
for command in ["delete", "resolve"] {
|
||||
for ids in [
|
||||
vec![],
|
||||
vec!["1"],
|
||||
vec!["0", "1"],
|
||||
vec!["-1", "1"],
|
||||
vec!["9223372036854775808", "1"],
|
||||
vec!["all", "1"],
|
||||
vec!["1", "0"],
|
||||
vec!["1", "-1"],
|
||||
vec!["1", "18446744073709551616"],
|
||||
vec!["1", "--json"],
|
||||
] {
|
||||
let mut args = std::iter::once(command).chain(ids).map(OsString::from);
|
||||
assert!(Request::parse(&mut args).is_err());
|
||||
}
|
||||
let mut args = [command, "9223372036854775807", "18446744073709551615"]
|
||||
.into_iter()
|
||||
.map(OsString::from);
|
||||
let mut request = Request::parse(&mut args).unwrap();
|
||||
assert_eq!(request.id, Some(i64::MAX));
|
||||
let (action, id) = request.comment.as_ref().unwrap();
|
||||
assert_eq!(*id, u64::MAX);
|
||||
assert!(matches!(
|
||||
(command, action),
|
||||
("delete", CommentAction::Delete) | ("resolve", CommentAction::Resolve)
|
||||
));
|
||||
assert!(request.option(OsStr::new("--all"), &mut args).is_err());
|
||||
request.option(OsStr::new("--json"), &mut args).unwrap();
|
||||
let mut repo = [OsString::from("checkout")].into_iter();
|
||||
request.option(OsStr::new("--repo"), &mut repo).unwrap();
|
||||
assert!(request.json);
|
||||
assert_eq!(request.repo, Some(PathBuf::from("checkout")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user