(t *testing.T)
| 119 | } |
| 120 | |
| 121 | func TestCompletionSubcommandOrder(t *testing.T) { |
| 122 | // The completion subcommands must appear in a deterministic order so that |
| 123 | // help output (and docs generated from it) does not change between runs. |
| 124 | // Previously they were built by iterating a map, whose order Go randomizes. |
| 125 | want := []string{"bash", "zsh", "fish", "pwsh"} |
| 126 | |
| 127 | // Build several times to guard against intra-process variation. |
| 128 | for range 10 { |
| 129 | cmd := buildCompletionCommand("foo") |
| 130 | |
| 131 | got := make([]string, 0, len(cmd.Commands)) |
| 132 | for _, sub := range cmd.Commands { |
| 133 | got = append(got, sub.Name) |
| 134 | } |
| 135 | |
| 136 | assert.Equal(t, want, got) |
| 137 | } |
| 138 | |
| 139 | // Every shell in shellCompletions must be represented in the ordered list. |
| 140 | assert.Len(t, completionShells, len(shellCompletions)) |
| 141 | for shell := range shellCompletions { |
| 142 | assert.Contains(t, completionShells, shell) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | func TestCompletionBashNoShebang(t *testing.T) { |
| 147 | // Regression test for https://github.com/urfave/cli/issues/2259 |
nothing calls this directly
no test coverage detected