(t *testing.T)
| 63 | } |
| 64 | |
| 65 | func TestCompleteContainerNames(t *testing.T) { |
| 66 | tests := []struct { |
| 67 | doc string |
| 68 | showAll, showIDs bool |
| 69 | filters []func(container.Summary) bool |
| 70 | containers []container.Summary |
| 71 | expOut []string |
| 72 | expOpts client.ContainerListOptions |
| 73 | expDirective cobra.ShellCompDirective |
| 74 | }{ |
| 75 | { |
| 76 | doc: "no results", |
| 77 | expDirective: cobra.ShellCompDirectiveNoFileComp, |
| 78 | }, |
| 79 | { |
| 80 | doc: "all containers", |
| 81 | showAll: true, |
| 82 | containers: []container.Summary{ |
| 83 | {ID: "id-c", State: container.StateRunning, Names: []string{"/container-c", "/container-c/link-b"}}, |
| 84 | {ID: "id-b", State: container.StateCreated, Names: []string{"/container-b"}}, |
| 85 | {ID: "id-a", State: container.StateExited, Names: []string{"/container-a"}}, |
| 86 | }, |
| 87 | expOut: []string{"container-c", "container-b", "container-a"}, |
| 88 | expOpts: client.ContainerListOptions{All: true}, |
| 89 | expDirective: cobra.ShellCompDirectiveNoFileComp, |
| 90 | }, |
| 91 | { |
| 92 | doc: "all containers with ids", |
| 93 | showAll: true, |
| 94 | showIDs: true, |
| 95 | containers: []container.Summary{ |
| 96 | {ID: "id-c", State: container.StateRunning, Names: []string{"/container-c", "/container-c/link-b"}}, |
| 97 | {ID: "id-b", State: container.StateCreated, Names: []string{"/container-b"}}, |
| 98 | {ID: "id-a", State: container.StateExited, Names: []string{"/container-a"}}, |
| 99 | }, |
| 100 | expOut: []string{"id-c", "container-c", "id-b", "container-b", "id-a", "container-a"}, |
| 101 | expOpts: client.ContainerListOptions{All: true}, |
| 102 | expDirective: cobra.ShellCompDirectiveNoFileComp, |
| 103 | }, |
| 104 | { |
| 105 | doc: "only running containers", |
| 106 | showAll: false, |
| 107 | containers: []container.Summary{ |
| 108 | {ID: "id-c", State: container.StateRunning, Names: []string{"/container-c", "/container-c/link-b"}}, |
| 109 | }, |
| 110 | expOut: []string{"container-c"}, |
| 111 | expDirective: cobra.ShellCompDirectiveNoFileComp, |
| 112 | }, |
| 113 | { |
| 114 | doc: "with filter", |
| 115 | showAll: true, |
| 116 | filters: []func(container.Summary) bool{ |
| 117 | func(ctr container.Summary) bool { return ctr.State == container.StateCreated }, |
| 118 | }, |
| 119 | containers: []container.Summary{ |
| 120 | {ID: "id-c", State: container.StateRunning, Names: []string{"/container-c"}}, |
| 121 | {ID: "id-b", State: container.StateCreated, Names: []string{"/container-b"}}, |
| 122 | {ID: "id-a", State: container.StateExited, Names: []string{"/container-a"}}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…