(t *testing.T)
| 281 | } |
| 282 | |
| 283 | func TestValidArgNames(t *testing.T) { |
| 284 | tests := []struct { |
| 285 | name string |
| 286 | valid []string |
| 287 | want []string |
| 288 | }{ |
| 289 | {"plain values", []string{"bash", "zsh"}, []string{"bash", "zsh"}}, |
| 290 | {"tab-separated descriptions are stripped", []string{"bash\tBourne again shell", "zsh\tZ shell"}, []string{"bash", "zsh"}}, |
| 291 | // Values pass through as cobra.OnlyValidArgs sees them, so the listed |
| 292 | // values are exactly the accepted ones. |
| 293 | {"values are not otherwise altered", []string{"bash", " fish"}, []string{"bash", " fish"}}, |
| 294 | {"none", nil, nil}, |
| 295 | } |
| 296 | |
| 297 | for _, tt := range tests { |
| 298 | t.Run(tt.name, func(t *testing.T) { |
| 299 | got := validArgNames(tt.valid) |
| 300 | if len(got) != len(tt.want) { |
| 301 | t.Fatalf("validArgNames(%v) = %v, want %v", tt.valid, got, tt.want) |
| 302 | } |
| 303 | for i := range got { |
| 304 | if got[i] != tt.want[i] { |
| 305 | t.Errorf("validArgNames(%v)[%d] = %q, want %q", tt.valid, i, got[i], tt.want[i]) |
| 306 | } |
| 307 | } |
| 308 | }) |
| 309 | } |
| 310 | } |
nothing calls this directly
no test coverage detected