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

Function TestStackList

cli/command/stack/list_test.go:68–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func 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 })

Callers

nothing calls this directly

Calls 4

OutBufferMethod · 0.95
newListCommandFunction · 0.70
StringMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…