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

Function TestRemoveStackSkipEmpty

cli/command/stack/remove_test.go:65–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestRemoveStackSkipEmpty(t *testing.T) {
66 allServices := []string{objectName("bar", "service1"), objectName("bar", "service2")}
67 allServiceIDs := buildObjectIDs(allServices)
68
69 allNetworks := []string{objectName("bar", "network1")}
70 allNetworkIDs := buildObjectIDs(allNetworks)
71
72 allSecrets := []string{objectName("bar", "secret1")}
73 allSecretIDs := buildObjectIDs(allSecrets)
74
75 allConfigs := []string{objectName("bar", "config1")}
76 allConfigIDs := buildObjectIDs(allConfigs)
77
78 apiClient := &fakeClient{
79 services: allServices,
80 networks: allNetworks,
81 secrets: allSecrets,
82 configs: allConfigs,
83 }
84 fakeCli := test.NewFakeCli(apiClient)
85 cmd := newRemoveCommand(fakeCli)
86 cmd.SetArgs([]string{"foo", "bar"})
87
88 assert.NilError(t, cmd.Execute())
89 expectedList := []string{
90 "Removing service bar_service1",
91 "Removing service bar_service2",
92 "Removing secret bar_secret1",
93 "Removing config bar_config1",
94 "Removing network bar_network1\n",
95 }
96 assert.Check(t, is.Equal(strings.Join(expectedList, "\n"), fakeCli.OutBuffer().String()))
97 assert.Check(t, is.Contains(fakeCli.ErrBuffer().String(), "Nothing found in stack: foo\n"))
98 assert.Check(t, is.DeepEqual(allServiceIDs, apiClient.removedServices))
99 assert.Check(t, is.DeepEqual(allNetworkIDs, apiClient.removedNetworks))
100 assert.Check(t, is.DeepEqual(allSecretIDs, apiClient.removedSecrets))
101 assert.Check(t, is.DeepEqual(allConfigIDs, apiClient.removedConfigs))
102}
103
104func TestRemoveContinueAfterError(t *testing.T) {
105 allServices := []string{objectName("foo", "service1"), objectName("bar", "service1")}

Callers

nothing calls this directly

Calls 8

OutBufferMethod · 0.95
ErrBufferMethod · 0.95
objectNameFunction · 0.85
buildObjectIDsFunction · 0.85
SetArgsMethod · 0.80
ContainsMethod · 0.80
newRemoveCommandFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…