MCPcopy
hub / github.com/spf13/cobra / TestEnableCommandSortingIsDisabled

Function TestEnableCommandSortingIsDisabled

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

Source from the content-addressed store, hash-verified

1933}
1934
1935func TestEnableCommandSortingIsDisabled(t *testing.T) {
1936 EnableCommandSorting = false
1937
1938 originalNames := []string{"middle", "zlast", "afirst"}
1939
1940 var rootCmd = &Command{Use: "root"}
1941
1942 for _, name := range originalNames {
1943 rootCmd.AddCommand(&Command{Use: name})
1944 }
1945
1946 for i, c := range rootCmd.Commands() {
1947 got := c.Name()
1948 if originalNames[i] != got {
1949 t.Errorf("expected: %s, got: %s", originalNames[i], got)
1950 }
1951 }
1952
1953 EnableCommandSorting = defaultCommandSorting
1954}
1955
1956func TestUsageWithGroup(t *testing.T) {
1957 var rootCmd = &Command{Use: "root", Short: "test", Run: emptyRun}

Callers

nothing calls this directly

Calls 3

AddCommandMethod · 0.80
CommandsMethod · 0.80
NameMethod · 0.80

Tested by

no test coverage detected