MCPcopy Create free account
hub / github.com/docker/cli / TestSecretCreateWithDriver

Function TestSecretCreateWithDriver

cli/command/secret/create_test.go:88–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestSecretCreateWithDriver(t *testing.T) {
89 expectedDriver := &swarm.Driver{
90 Name: "secret-driver",
91 }
92 const name = "secret-with-driver"
93
94 cli := test.NewFakeCli(&fakeClient{
95 secretCreateFunc: func(_ context.Context, options client.SecretCreateOptions) (client.SecretCreateResult, error) {
96 if options.Spec.Name != name {
97 return client.SecretCreateResult{}, fmt.Errorf("expected name %q, got %q", name, options.Spec.Name)
98 }
99
100 if options.Spec.Driver.Name != expectedDriver.Name {
101 return client.SecretCreateResult{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, options.Spec.Labels)
102 }
103
104 return client.SecretCreateResult{
105 ID: "ID-" + options.Spec.Name,
106 }, nil
107 },
108 })
109
110 cmd := newSecretCreateCommand(cli)
111 cmd.SetArgs([]string{name})
112 assert.Check(t, cmd.Flags().Set("driver", expectedDriver.Name))
113 assert.NilError(t, cmd.Execute())
114 assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
115}
116
117func TestSecretCreateWithTemplatingDriver(t *testing.T) {
118 expectedDriver := &swarm.Driver{

Callers

nothing calls this directly

Calls 5

OutBufferMethod · 0.95
newSecretCreateCommandFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…