TestSetConfigsNoConfigs checks that setConfigs works when there are no configs of any kind needed
(t *testing.T)
| 234 | // TestSetConfigsNoConfigs checks that setConfigs works when there are no |
| 235 | // configs of any kind needed |
| 236 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…