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

Function TestConfigCreateWithTemplatingDriver

cli/command/config/create_test.go:123–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

121}
122
123func TestConfigCreateWithTemplatingDriver(t *testing.T) {
124 expectedDriver := &swarm.Driver{
125 Name: "template-driver",
126 }
127 const name = "config-with-template-driver"
128
129 cli := test.NewFakeCli(&fakeClient{
130 configCreateFunc: func(_ context.Context, options client.ConfigCreateOptions) (client.ConfigCreateResult, error) {
131 if options.Spec.Name != name {
132 return client.ConfigCreateResult{}, fmt.Errorf("expected name %q, got %q", name, options.Spec.Name)
133 }
134
135 if options.Spec.Templating.Name != expectedDriver.Name {
136 return client.ConfigCreateResult{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, options.Spec.Labels)
137 }
138
139 return client.ConfigCreateResult{
140 ID: "ID-" + options.Spec.Name,
141 }, nil
142 },
143 })
144
145 cmd := newConfigCreateCommand(cli)
146 cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)})
147 cmd.Flags().Set("template-driver", expectedDriver.Name)
148 assert.NilError(t, cmd.Execute())
149 assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
150}

Callers

nothing calls this directly

Calls 5

OutBufferMethod · 0.95
newConfigCreateCommandFunction · 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…