Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepySkeleton committed Apr 24, 2020
1 parent 61a12e4 commit 7a09195
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions tests/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,27 @@ USAGE:
For more information try --help";

#[allow(unused)]
static REQ_GROUP_CONFLICT_REV: &str = "error: The argument '--delete' cannot be used with '<base>'
USAGE:
clap-test <base|--delete>
For more information try --help";

static REQ_GROUP_CONFLICT_ONLY_OPTIONS: &str =
"error: Found argument '--all' which wasn't expected, or isn't valid in this context
If you tried to supply `--all` as a PATTERN use `-- --all`
USAGE:
clap-test <-a|--delete>
For more information try --help";

// FIXME: This message has regressed after https://github.com/clap-rs/clap/pull/1856
// Need to roll back somehow.
static REQ_GROUP_CONFLICT_REV: &str =
static REQ_GROUP_CONFLICT_REV_DEGRADED: &str =
"error: Found argument 'base' which wasn't expected, or isn't valid in this context
If you tried to supply `base` as a PATTERN use `-- base`
Expand Down Expand Up @@ -213,7 +231,28 @@ fn req_group_with_conflict_usage_string() {
assert!(utils::compare_output2(
app,
"clap-test --delete base",
REQ_GROUP_CONFLICT_REV,
REQ_GROUP_CONFLICT_REV_DEGRADED,
REQ_GROUP_CONFLICT_USAGE,
true
));
}

#[test]
fn req_group_with_conflict_usage_string_only_options() {
let app = App::new("req_group")
.arg(Arg::from("<all> -a, -all 'All'").conflicts_with("delete"))
.arg(Arg::from(
"<delete> -d, --delete 'Remove the base commit information'",
))
.group(
ArgGroup::with_name("all_or_delete")
.args(&["all", "delete"])
.required(true),
);
assert!(utils::compare_output2(
app,
"clap-test --delete --all",
REQ_GROUP_CONFLICT_ONLY_OPTIONS,
REQ_GROUP_CONFLICT_USAGE,
true
));
Expand Down

0 comments on commit 7a09195

Please sign in to comment.