TestUpdateSecretUpdateInPlace tests the ability to update the "target" of a secret with "docker service update" by combining "--secret-rm" and "--secret-add" for the same secret.
(t *testing.T)
| 529 | // secret with "docker service update" by combining "--secret-rm" and |
| 530 | // "--secret-add" for the same secret. |
| 531 | func TestUpdateSecretUpdateInPlace(t *testing.T) { |
| 532 | apiClient := secretAPIClientMock{ |
| 533 | listResult: client.SecretListResult{ |
| 534 | Items: []swarm.Secret{{ |
| 535 | ID: "tn9qiblgnuuut11eufquw5dev", |
| 536 | Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "foo"}}, |
| 537 | }}, |
| 538 | }, |
| 539 | } |
| 540 | |
| 541 | flags := newUpdateCommand(nil).Flags() |
| 542 | flags.Set("secret-add", "source=foo,target=foo2") |
| 543 | flags.Set("secret-rm", "foo") |
| 544 | |
| 545 | secrets := []*swarm.SecretReference{ |
| 546 | { |
| 547 | File: &swarm.SecretReferenceFileTarget{ |
| 548 | Name: "foo", |
| 549 | UID: "0", |
| 550 | GID: "0", |
| 551 | Mode: 292, |
| 552 | }, |
| 553 | SecretID: "tn9qiblgnuuut11eufquw5dev", |
| 554 | SecretName: "foo", |
| 555 | }, |
| 556 | } |
| 557 | |
| 558 | ctx := context.Background() |
| 559 | updatedSecrets, err := getUpdatedSecrets(ctx, apiClient, flags, secrets) |
| 560 | |
| 561 | assert.NilError(t, err) |
| 562 | assert.Assert(t, is.Len(updatedSecrets, 1)) |
| 563 | assert.Check(t, is.Equal("tn9qiblgnuuut11eufquw5dev", updatedSecrets[0].SecretID)) |
| 564 | assert.Check(t, is.Equal("foo", updatedSecrets[0].SecretName)) |
| 565 | assert.Check(t, is.Equal("foo2", updatedSecrets[0].File.Name)) |
| 566 | } |
| 567 | |
| 568 | func TestUpdateReadOnly(t *testing.T) { |
| 569 | spec := &swarm.ServiceSpec{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…