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

Function TestCompletePid

cli/command/container/completion_test.go:28–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestCompletePid(t *testing.T) {
29 tests := []struct {
30 containerListFunc func(client.ContainerListOptions) (client.ContainerListResult, error)
31 toComplete string
32 expectedCompletions []string
33 expectedDirective cobra.ShellCompDirective
34 }{
35 {
36 toComplete: "",
37 expectedCompletions: []string{"container:", "host"},
38 expectedDirective: cobra.ShellCompDirectiveNoFileComp,
39 },
40 {
41 toComplete: "c",
42 expectedCompletions: []string{"container:"},
43 expectedDirective: cobra.ShellCompDirectiveNoSpace,
44 },
45 {
46 containerListFunc: func(client.ContainerListOptions) (client.ContainerListResult, error) {
47 return client.ContainerListResult{
48 Items: []container.Summary{
49 *builders.Container("c1"),
50 *builders.Container("c2"),
51 },
52 }, nil
53 },
54 toComplete: "container:",
55 expectedCompletions: []string{"container:c1", "container:c2"},
56 expectedDirective: cobra.ShellCompDirectiveNoFileComp,
57 },
58 }
59
60 for _, tc := range tests {
61 t.Run(tc.toComplete, func(t *testing.T) {
62 cli := test.NewFakeCli(&fakeClient{
63 containerListFunc: tc.containerListFunc,
64 })
65 completions, directive := completePid(cli)(newRunCommand(cli), nil, tc.toComplete)
66 assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions))
67 assert.Check(t, is.Equal(directive, tc.expectedDirective))
68 })
69 }
70}
71
72func TestCompleteRestartPolicies(t *testing.T) {
73 values, directives := completeRestartPolicies(nil, nil, "")

Callers

nothing calls this directly

Calls 3

completePidFunction · 0.85
newRunCommandFunction · 0.85
ContainerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…