MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestValidArgNames

Function TestValidArgNames

cmd/opencodereview/arg_errors_test.go:268–295  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

266}
267
268func 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}

Callers

nothing calls this directly

Calls 2

validArgNamesFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected