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

Function TestSecretCreateWithTemplatingDriver

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

Source from the content-addressed store, hash-verified

115}
116
117func TestSecretCreateWithTemplatingDriver(t *testing.T) {
118 expectedDriver := &swarm.Driver{
119 Name: "template-driver",
120 }
121 const name = "secret-with-template-driver"
122
123 cli := test.NewFakeCli(&fakeClient{
124 secretCreateFunc: func(_ context.Context, options client.SecretCreateOptions) (client.SecretCreateResult, error) {
125 if options.Spec.Name != name {
126 return client.SecretCreateResult{}, fmt.Errorf("expected name %q, got %q", name, options.Spec.Name)
127 }
128
129 if options.Spec.Templating.Name != expectedDriver.Name {
130 return client.SecretCreateResult{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, options.Spec.Labels)
131 }
132
133 return client.SecretCreateResult{
134 ID: "ID-" + options.Spec.Name,
135 }, nil
136 },
137 })
138
139 cmd := newSecretCreateCommand(cli)
140 cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)})
141 assert.Check(t, cmd.Flags().Set("template-driver", expectedDriver.Name))
142 assert.NilError(t, cmd.Execute())
143 assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
144}
145
146func TestSecretCreateWithLabels(t *testing.T) {
147 expectedLabels := map[string]string{

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…