From bcf43a86837dd83e934c5c2bc5a4470c2686b429 Mon Sep 17 00:00:00 2001 From: steven-omaha <35634100+steven-omaha@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:37:57 +0200 Subject: [PATCH] test(args): add negative test cases --- crates/pacdef_core/src/args/tests.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/pacdef_core/src/args/tests.rs b/crates/pacdef_core/src/args/tests.rs index da641c9..a4b34d1 100644 --- a/crates/pacdef_core/src/args/tests.rs +++ b/crates/pacdef_core/src/args/tests.rs @@ -25,3 +25,14 @@ fn arg_parsing(#[case] input: Vec<&str>, #[case] expected: Arguments) { assert_eq!(parsed, expected); } + +#[rstest] +#[should_panic] +#[case(vec!["pacdef", "package", "search"], "regex missing")] +#[should_panic] +#[case(vec!["pacdef", "p", "s"], "can be either 'sync' or 'search'")] +#[should_panic] +#[case(vec!["pacdef", "group", "edit"], "group missing")] +fn arg_parsing_invalid(#[case] input: Vec<&str>, #[case] err_msg: &str) { + build_cli().try_get_matches_from(input).expect(err_msg); +}