(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestStackList(t *testing.T) { |
| 69 | testCases := []struct { |
| 70 | doc string |
| 71 | serviceNames []string |
| 72 | flags map[string]string |
| 73 | golden string |
| 74 | }{ |
| 75 | { |
| 76 | doc: "WithFormat", |
| 77 | serviceNames: []string{"service-name-foo"}, |
| 78 | flags: map[string]string{ |
| 79 | "format": "{{ .Name }}", |
| 80 | }, |
| 81 | golden: "stack-list-with-format.golden", |
| 82 | }, |
| 83 | { |
| 84 | doc: "WithoutFormat", |
| 85 | serviceNames: []string{"service-name-foo"}, |
| 86 | golden: "stack-list-without-format.golden", |
| 87 | }, |
| 88 | { |
| 89 | doc: "Sort", |
| 90 | serviceNames: []string{ |
| 91 | "service-name-foo", |
| 92 | "service-name-bar", |
| 93 | }, |
| 94 | golden: "stack-list-sort.golden", |
| 95 | }, |
| 96 | { |
| 97 | doc: "SortNatural", |
| 98 | serviceNames: []string{ |
| 99 | "service-name-1-foo", |
| 100 | "service-name-10-foo", |
| 101 | "service-name-2-foo", |
| 102 | }, |
| 103 | golden: "stack-list-sort-natural.golden", |
| 104 | }, |
| 105 | } |
| 106 | |
| 107 | for _, tc := range testCases { |
| 108 | t.Run(tc.doc, func(t *testing.T) { |
| 109 | var services []swarm.Service |
| 110 | for _, name := range tc.serviceNames { |
| 111 | services = append(services, |
| 112 | *builders.Service( |
| 113 | builders.ServiceLabels(map[string]string{ |
| 114 | "com.docker.stack.namespace": name, |
| 115 | }), |
| 116 | ), |
| 117 | ) |
| 118 | } |
| 119 | cli := test.NewFakeCli(&fakeClient{ |
| 120 | serviceListFunc: func(options client.ServiceListOptions) (client.ServiceListResult, error) { |
| 121 | return client.ServiceListResult{ |
| 122 | Items: services, |
| 123 | }, nil |
| 124 | }, |
| 125 | }) |
nothing calls this directly
no test coverage detected
searching dependent graphs…