(t *testing.T)
| 157 | } |
| 158 | |
| 159 | func TestUpdateCmd_Completion(t *testing.T) { |
| 160 | // Cleanup. |
| 161 | dirs.RemoveAllForTest() |
| 162 | |
| 163 | // Check error. |
| 164 | var check = func(err error) { |
| 165 | t.Helper() |
| 166 | if err != nil { |
| 167 | t.Fatal(err) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // Init celer. |
| 172 | celer := configs.NewCeler() |
| 173 | check(celer.Init()) |
| 174 | |
| 175 | updateCmd := updateCmd{celer: celer} |
| 176 | cmd := updateCmd.Command(celer) |
| 177 | |
| 178 | tests := []struct { |
| 179 | name string |
| 180 | toComplete string |
| 181 | expected []string |
| 182 | }{ |
| 183 | { |
| 184 | name: "complete_conf_repo_flag", |
| 185 | toComplete: "--conf", |
| 186 | expected: []string{"--conf-repo"}, |
| 187 | }, |
| 188 | { |
| 189 | name: "complete_conf_repo_short_flag", |
| 190 | toComplete: "-c", |
| 191 | expected: []string{"-c"}, |
| 192 | }, |
| 193 | { |
| 194 | name: "complete_ports_repo_flag", |
| 195 | toComplete: "--ports", |
| 196 | expected: []string{"--ports-repo"}, |
| 197 | }, |
| 198 | { |
| 199 | name: "complete_force_flag", |
| 200 | toComplete: "--f", |
| 201 | expected: []string{"--force"}, |
| 202 | }, |
| 203 | { |
| 204 | name: "complete_recursive_flag", |
| 205 | toComplete: "--r", |
| 206 | expected: []string{"--recursive"}, |
| 207 | }, |
| 208 | { |
| 209 | name: "no_completion_for_random", |
| 210 | toComplete: "--random", |
| 211 | expected: []string{}, |
| 212 | }, |
| 213 | } |
| 214 | |
| 215 | for _, test := range tests { |
| 216 | t.Run(test.name, func(t *testing.T) { |
nothing calls this directly
no test coverage detected