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

Function TestSetConfigsNoConfigs

cli/command/service/create_test.go:236–269  ·  view source on GitHub ↗

TestSetConfigsNoConfigs checks that setConfigs works when there are no configs of any kind needed

(t *testing.T)

Source from the content-addressed store, hash-verified

234// TestSetConfigsNoConfigs checks that setConfigs works when there are no
235// configs of any kind needed
236func TestSetConfigsNoConfigs(t *testing.T) {
237 // add a credentialSpec that isn't a config
238 opts := &serviceOptions{
239 credentialSpec: credentialSpecOpt{
240 value: &swarm.CredentialSpec{
241 File: "foo",
242 },
243 source: "file://foo",
244 },
245 }
246 service := &swarm.ServiceSpec{
247 TaskTemplate: swarm.TaskSpec{
248 ContainerSpec: &swarm.ContainerSpec{
249 Privileges: &swarm.Privileges{
250 CredentialSpec: opts.credentialSpec.value,
251 },
252 },
253 },
254 }
255
256 fakeConfigClient := fakeConfigAPIClientList(func(_ context.Context, opts client.ConfigListOptions) (client.ConfigListResult, error) {
257 // assert false -- we should never call this function
258 assert.Assert(t, false, "we should not be listing configs")
259 return client.ConfigListResult{}, nil
260 })
261
262 ctx := context.Background()
263 err := setConfigs(ctx, fakeConfigClient, service, opts)
264 assert.NilError(t, err)
265
266 // ensure that the value of the credential-spec has not changed
267 assert.Equal(t, service.TaskTemplate.ContainerSpec.Privileges.CredentialSpec.File, "foo")
268 assert.Equal(t, service.TaskTemplate.ContainerSpec.Privileges.CredentialSpec.Config, "")
269}

Callers

nothing calls this directly

Calls 2

fakeConfigAPIClientListFuncType · 0.85
setConfigsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…