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

Function TestUpdateSecretUpdateInPlace

cli/command/service/update_test.go:531–566  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

529// secret with "docker service update" by combining "--secret-rm" and
530// "--secret-add" for the same secret.
531func 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
568func TestUpdateReadOnly(t *testing.T) {
569 spec := &swarm.ServiceSpec{

Callers

nothing calls this directly

Calls 4

getUpdatedSecretsFunction · 0.85
newUpdateCommandFunction · 0.70
SetMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…