(t *testing.T)
| 266 | } |
| 267 | |
| 268 | func TestValidArgNames(t *testing.T) { |
| 269 | tests := []struct { |
| 270 | name string |
| 271 | valid []string |
| 272 | want []string |
| 273 | }{ |
| 274 | {"plain values", []string{"bash", "zsh"}, []string{"bash", "zsh"}}, |
| 275 | {"tab-separated descriptions are stripped", []string{"bash\tBourne again shell", "zsh\tZ shell"}, []string{"bash", "zsh"}}, |
| 276 | // Values pass through as cobra.OnlyValidArgs sees them, so the listed |
| 277 | // values are exactly the accepted ones. |
| 278 | {"values are not otherwise altered", []string{"bash", " fish"}, []string{"bash", " fish"}}, |
| 279 | {"none", nil, nil}, |
| 280 | } |
| 281 | |
| 282 | for _, tt := range tests { |
| 283 | t.Run(tt.name, func(t *testing.T) { |
| 284 | got := validArgNames(tt.valid) |
| 285 | if len(got) != len(tt.want) { |
| 286 | t.Fatalf("validArgNames(%v) = %v, want %v", tt.valid, got, tt.want) |
| 287 | } |
| 288 | for i := range got { |
| 289 | if got[i] != tt.want[i] { |
| 290 | t.Errorf("validArgNames(%v)[%d] = %q, want %q", tt.valid, i, got[i], tt.want[i]) |
| 291 | } |
| 292 | } |
| 293 | }) |
| 294 | } |
| 295 | } |
nothing calls this directly
no test coverage detected