Skip to content

test: fix ineffective mutex error-string assertion and add mirror cases - #2410

Merged
dearchap merged 1 commit into
urfave:mainfrom
dearchap:issue_2404
Aug 16, 2026
Merged

test: fix ineffective mutex error-string assertion and add mirror cases#2410
dearchap merged 1 commit into
urfave:mainfrom
dearchap:issue_2404

Conversation

@dearchap

Copy link
Copy Markdown
Contributor

What type of PR is this?

bugfix (test harness only)

What this PR does / why we need it:

Fixes #2404.

Found while reviewing #2386. Three changes in flag_mutex_test.go:

  • Ineffective assertion: the error-string check used t.Logf instead of
    t.Errorf/assert.Contains, so a wrong error message never failed the
    test. This was masking that the message reports the flag's primary name
    (Names()[0]) rather than the alias typed on the command line.
  • Align expectation with actual behavior: the error message references
    the primary flag name (consistent with how required-flag errors are
    reported elsewhere in the codebase, e.g. checkRequiredFlag in
    command.go), so the --ai expectation becomes t.
  • Coverage gap: adds --i --q (first member of group 0 × second member
    of group 1) and --s --q (second member of group 0 × second member of
    group 1) to pin the cross-group fix from Fix Issue #2385 #2386.

Which issue(s) this PR fixes

Fixes #2404

Testing

Ran go test -count=1 -run TestFlagMutuallyExclusiveFlags -v ., go vet ./...,
goimports -l ., and go test -count=1 -race ./.... All pass.

Release Notes

NONE

The assertion checking the mutually exclusive error string used t.Logf
instead of t.Errorf, so a wrong error message never failed the test.
This masked that the message reports the flag's primary name (Names()[0])
rather than the alias typed on the command line. Align the expectation
with the actual (and codebase-consistent) behavior.

Also add coverage for cross-group combinations where the conflicting flag
is not the first member of its group: --i --q and --s --q.
@dearchap
dearchap requested a review from a team as a code owner August 16, 2026 14:55
@dearchap
dearchap merged commit 138d3b3 into urfave:main Aug 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flag_mutex_test.go: ineffective error-string assertion masks wrong error message

1 participant