Add test coverage for Command.VisibleCommands()

This commit is contained in:
Naveen Gogineni 2022-10-05 13:52:05 -04:00 committed by Dan Buch
parent a4b7759ad1
commit 9a9461928a
Signed by: meatballhat
GPG Key ID: A12F782281063434

View File

@ -422,3 +422,30 @@ func TestCommand_CanAddVFlagOnCommands(t *testing.T) {
err := app.Run([]string{"foo", "bar"})
expect(t, err, nil)
}
func TestCommand_VisibleSubcCommands(t *testing.T) {
subc1 := &Command{
Name: "subc1",
Usage: "subc1 command1",
}
subc3 := &Command{
Name: "subc3",
Usage: "subc3 command2",
}
c := &Command{
Name: "bar",
Usage: "this is for testing",
Subcommands: []*Command{
subc1,
{
Name: "subc2",
Usage: "subc2 command2",
Hidden: true,
},
subc3,
},
}
expect(t, c.VisibleCommands(), []*Command{subc1, subc3})
}