MCPcopy
hub / github.com/urfave/cli / TestCommand_VisibleCategories

Function TestCommand_VisibleCategories

command_test.go:2788–2884  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2786}
2787
2788func TestCommand_VisibleCategories(t *testing.T) {
2789 cmd := &Command{
2790 Name: "visible-categories",
2791 HideHelp: true,
2792 Commands: []*Command{
2793 {
2794 Name: "command1",
2795 Category: "1",
2796 Hidden: true,
2797 },
2798 {
2799 Name: "command2",
2800 Category: "2",
2801 },
2802 {
2803 Name: "command3",
2804 Category: "3",
2805 },
2806 },
2807 }
2808
2809 expected := []CommandCategory{
2810 &commandCategory{
2811 name: "2",
2812 commands: []*Command{
2813 cmd.Commands[1],
2814 },
2815 },
2816 &commandCategory{
2817 name: "3",
2818 commands: []*Command{
2819 cmd.Commands[2],
2820 },
2821 },
2822 }
2823
2824 cmd.setupDefaults([]string{"test"})
2825 assert.Equal(t, expected, cmd.VisibleCategories())
2826
2827 cmd = &Command{
2828 Name: "visible-categories",
2829 HideHelp: true,
2830 Commands: []*Command{
2831 {
2832 Name: "command1",
2833 Category: "1",
2834 Hidden: true,
2835 },
2836 {
2837 Name: "command2",
2838 Category: "2",
2839 Hidden: true,
2840 },
2841 {
2842 Name: "command3",
2843 Category: "3",
2844 },
2845 },

Callers

nothing calls this directly

Calls 2

setupDefaultsMethod · 0.95
VisibleCategoriesMethod · 0.95

Tested by

no test coverage detected