Skip to content

Commit

Permalink
test(context): Added regression test for requiredFlagsError
Browse files Browse the repository at this point in the history
This adds a test verifying that the requiredFlagsError does contain the long
option of the missing flag, instead of the short option and a space, which was
the old behaviour.

Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
  • Loading branch information
Ole Petter committed May 2, 2020
1 parent 053ba9d commit f842187
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ func TestCheckRequiredFlags(t *testing.T) {
},
parseInput: []string{"-n", "asd", "-n", "qwe"},
},
{
testCase: "required_flag_with_short_alias_not_printed_on_error",
expectedAnError: true,
expectedErrorContents: []string{"Required flag \"names\" not set"},
flags: []Flag{
StringSliceFlag{Name: "names, n", Required: true},
},
},
}
for _, test := range tdata {
t.Run(test.testCase, func(t *testing.T) {
Expand Down

0 comments on commit f842187

Please sign in to comment.