test for version flag on commands
This commit is contained in:
parent
6d09498169
commit
44371a2ac6
@ -377,3 +377,27 @@ func TestCommand_Run_CustomShellCompleteAcceptsMalformedFlags(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCommand_NoVersionFlagOnCommands(t *testing.T) {
|
||||
app := &App{
|
||||
Version: "some version",
|
||||
Commands: []*Command{
|
||||
{
|
||||
Name: "bar",
|
||||
Usage: "this is for testing",
|
||||
Subcommands: []*Command{{}}, // some subcommand
|
||||
Action: func(c *Context) error {
|
||||
for _, f := range c.App.VisibleFlags() {
|
||||
if f == VersionFlag {
|
||||
t.Fatalf("unexpected version flag")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := app.Run([]string{"foo", "bar"})
|
||||
expect(t, err, nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user