MCPcopy
hub / github.com/helm/helm / checkCommand

Function checkCommand

pkg/cmd/plugin_test.go:276–303  ·  view source on GitHub ↗
(t *testing.T, plugins []*cobra.Command, tests []staticCompletionDetails)

Source from the content-addressed store, hash-verified

274}
275
276func checkCommand(t *testing.T, plugins []*cobra.Command, tests []staticCompletionDetails) {
277 t.Helper()
278 require.Len(t, plugins, len(tests), "Expected commands %v, got %v", tests, plugins)
279
280 is := assert.New(t)
281 for i := range plugins {
282 pp := plugins[i]
283 tt := tests[i]
284 is.Equal(pp.Use, tt.use, "Expected Use=%q, got %q", tt.use, pp.Use)
285
286 targs := tt.validArgs
287 pargs := pp.ValidArgs
288 is.ElementsMatch(targs, pargs)
289
290 tflags := tt.flags
291 var pflags []string
292 pp.LocalFlags().VisitAll(func(flag *pflag.Flag) {
293 pflags = append(pflags, flag.Name)
294 if len(flag.Shorthand) > 0 && flag.Shorthand != flag.Name {
295 pflags = append(pflags, flag.Shorthand)
296 }
297 })
298 is.ElementsMatch(tflags, pflags)
299
300 // Check the next level
301 checkCommand(t, pp.Commands(), tt.next)
302 }
303}
304
305func TestPluginDynamicCompletion(t *testing.T) {
306 tests := []cmdTestCase{{

Callers 1

Calls 2

HelperMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…