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

Function TestRemoveContinueAfterError

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

Source from the content-addressed store, hash-verified

102}
103
104func TestRemoveContinueAfterError(t *testing.T) {
105 allServices := []string{objectName("foo", "service1"), objectName("bar", "service1")}
106 allServiceIDs := buildObjectIDs(allServices)
107
108 allNetworks := []string{objectName("foo", "network1"), objectName("bar", "network1")}
109 allNetworkIDs := buildObjectIDs(allNetworks)
110
111 allSecrets := []string{objectName("foo", "secret1"), objectName("bar", "secret1")}
112 allSecretIDs := buildObjectIDs(allSecrets)
113
114 allConfigs := []string{objectName("foo", "config1"), objectName("bar", "config1")}
115 allConfigIDs := buildObjectIDs(allConfigs)
116
117 var removedServices []string
118 apiClient := &fakeClient{
119 services: allServices,
120 networks: allNetworks,
121 secrets: allSecrets,
122 configs: allConfigs,
123
124 serviceRemoveFunc: func(serviceID string) (client.ServiceRemoveResult, error) {
125 removedServices = append(removedServices, serviceID)
126
127 if strings.Contains(serviceID, "foo") {
128 return client.ServiceRemoveResult{}, errors.New("")
129 }
130 return client.ServiceRemoveResult{}, nil
131 },
132 }
133 cmd := newRemoveCommand(test.NewFakeCli(apiClient))
134 cmd.SetOut(io.Discard)
135 cmd.SetErr(io.Discard)
136 cmd.SetArgs([]string{"foo", "bar"})
137
138 assert.Error(t, cmd.Execute(), "failed to remove some resources from stack: foo")
139 assert.Check(t, is.DeepEqual(allServiceIDs, removedServices))
140 assert.Check(t, is.DeepEqual(allNetworkIDs, apiClient.removedNetworks))
141 assert.Check(t, is.DeepEqual(allSecretIDs, apiClient.removedSecrets))
142 assert.Check(t, is.DeepEqual(allConfigIDs, apiClient.removedConfigs))
143}

Callers

nothing calls this directly

Calls 8

objectNameFunction · 0.85
buildObjectIDsFunction · 0.85
ContainsMethod · 0.80
SetArgsMethod · 0.80
newRemoveCommandFunction · 0.70
SetOutMethod · 0.45
SetErrMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…