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

Function TestCompleteLinks

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

Source from the content-addressed store, hash-verified

137}
138
139func TestCompleteLinks(t *testing.T) {
140 tests := []struct {
141 doc string
142 showAll, showIDs bool
143 filters []func(container.Summary) bool
144 containers []container.Summary
145 expOut []string
146 expDirective cobra.ShellCompDirective
147 }{
148 {
149 doc: "no results",
150 expDirective: cobra.ShellCompDirectiveNoFileComp,
151 },
152 {
153 doc: "all containers",
154 showAll: true,
155 containers: []container.Summary{
156 {ID: "id-c", State: container.StateRunning, Names: []string{"/container-c", "/container-c/link-b", "/container-c/link-c"}},
157 {ID: "id-b", State: container.StateCreated, Names: []string{"/container-b", "/container-b/link-a"}},
158 {ID: "id-a", State: container.StateExited, Names: []string{"/container-a"}},
159 },
160 expOut: []string{"container-c/link-b", "container-c/link-c", "container-b/link-a"},
161 expDirective: cobra.ShellCompDirectiveNoFileComp,
162 },
163 }
164
165 for _, tc := range tests {
166 t.Run(tc.doc, func(t *testing.T) {
167 comp := completeLinks(test.NewFakeCli(&fakeClient{
168 containerListFunc: func(client.ContainerListOptions) (client.ContainerListResult, error) {
169 return client.ContainerListResult{Items: tc.containers}, nil
170 },
171 }))
172
173 containers, directives := comp(&cobra.Command{}, nil, "")
174 assert.Check(t, is.Equal(directives&tc.expDirective, tc.expDirective))
175 assert.Check(t, is.DeepEqual(containers, tc.expOut))
176 })
177 }
178}

Callers

nothing calls this directly

Calls 1

completeLinksFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…