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

Function TestCompleteEventFilter

cli/command/system/completion_test.go:22–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestCompleteEventFilter(t *testing.T) {
23 tests := []struct {
24 client *fakeClient
25 toComplete string
26 expected []string
27 }{
28 {
29 client: &fakeClient{
30 containerListFunc: func(_ context.Context, _ client.ContainerListOptions) ([]container.Summary, error) {
31 return []container.Summary{
32 *builders.Container("c1"),
33 *builders.Container("c2"),
34 }, nil
35 },
36 },
37 toComplete: "container=",
38 expected: []string{"container=c1", "container=c2"},
39 },
40 {
41 client: &fakeClient{
42 containerListFunc: func(_ context.Context, _ client.ContainerListOptions) ([]container.Summary, error) {
43 return nil, errors.New("API error")
44 },
45 },
46 toComplete: "container=",
47 expected: []string{},
48 },
49 {
50 client: &fakeClient{
51 infoFunc: func(_ context.Context, _ client.InfoOptions) (client.SystemInfoResult, error) {
52 return client.SystemInfoResult{
53 Info: system.Info{
54 ID: "daemon-id",
55 Name: "daemon-name",
56 },
57 }, nil
58 },
59 },
60 toComplete: "daemon=",
61 expected: []string{"daemon=daemon-name", "daemon=daemon-id"},
62 },
63 {
64 client: &fakeClient{
65 infoFunc: func(_ context.Context, _ client.InfoOptions) (client.SystemInfoResult, error) {
66 return client.SystemInfoResult{}, errors.New("API error")
67 },
68 },
69 toComplete: "daemon=",
70 expected: []string{},
71 },
72 {
73 client: &fakeClient{
74 imageListFunc: func(ctx context.Context, options client.ImageListOptions) (client.ImageListResult, error) {
75 return client.ImageListResult{
76 Items: []image.Summary{
77 {RepoTags: []string{"img:1"}},
78 {RepoTags: []string{"img:2"}},
79 },

Callers

nothing calls this directly

Calls 5

completeEventFiltersFunction · 0.85
newEventsCommandFunction · 0.85
ContainerMethod · 0.80
NodeMethod · 0.80
HostnameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…