MCPcopy Index your code
hub / github.com/docker/cli / TestUnique

Function TestUnique

cli/command/completion/functions_test.go:355–373  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

353}
354
355func TestUnique(t *testing.T) {
356 base := []string{"alpha", "beta", "gamma"}
357
358 comp := Unique(func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
359 return base, cobra.ShellCompDirectiveNoFileComp
360 })
361
362 values, directives := comp(&cobra.Command{}, []string{"beta"}, "")
363 assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp))
364 assert.Check(t, is.DeepEqual(values, []string{"alpha", "gamma"}))
365
366 assert.Check(t, is.DeepEqual(base, []string{"alpha", "beta", "gamma"}))
367
368 values, directives = comp(&cobra.Command{}, []string{"gamma"}, "")
369 assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp))
370 assert.Check(t, is.DeepEqual(values, []string{"alpha", "beta"}))
371
372 assert.Check(t, is.DeepEqual(base, []string{"alpha", "beta", "gamma"}))
373}

Callers

nothing calls this directly

Calls 1

UniqueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…