Skip to content

Commit 65c6366

Browse files
authored
Add test for MutuallyExclusiveFlags with After (urfave#2107)
For urfave#2098
1 parent 2ec3c16 commit 65c6366

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

command_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5011,3 +5011,38 @@ func TestJSONExportCommand(t *testing.T) {
50115011
`
50125012
assert.JSONEq(t, expected, string(out))
50135013
}
5014+
5015+
func TestCommand_ExclusiveFlagsWithAfter(t *testing.T) {
5016+
var called bool
5017+
cmd := &Command{
5018+
Name: "bar",
5019+
MutuallyExclusiveFlags: []MutuallyExclusiveFlags{
5020+
{
5021+
Category: "cat1",
5022+
Flags: [][]Flag{
5023+
{
5024+
&StringFlag{
5025+
Name: "foo",
5026+
},
5027+
},
5028+
{
5029+
&StringFlag{
5030+
Name: "foo2",
5031+
},
5032+
},
5033+
},
5034+
},
5035+
},
5036+
After: func(ctx context.Context, cmd *Command) error {
5037+
called = true
5038+
return nil
5039+
},
5040+
}
5041+
5042+
require.Error(t, cmd.Run(buildTestContext(t), []string{
5043+
"bar",
5044+
"--foo", "v1",
5045+
"--foo2", "v2",
5046+
}))
5047+
require.True(t, called)
5048+
}

0 commit comments

Comments
 (0)