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

Function TestConfigCreateWithName

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

Source from the content-addressed store, hash-verified

59}
60
61func TestConfigCreateWithName(t *testing.T) {
62 const name = "config-with-name"
63 var actual []byte
64 cli := test.NewFakeCli(&fakeClient{
65 configCreateFunc: func(_ context.Context, options client.ConfigCreateOptions) (client.ConfigCreateResult, error) {
66 if options.Spec.Name != name {
67 return client.ConfigCreateResult{}, fmt.Errorf("expected name %q, got %q", name, options.Spec.Name)
68 }
69
70 actual = options.Spec.Data
71
72 return client.ConfigCreateResult{
73 ID: "ID-" + options.Spec.Name,
74 }, nil
75 },
76 })
77
78 cmd := newConfigCreateCommand(cli)
79 cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)})
80 assert.NilError(t, cmd.Execute())
81 golden.Assert(t, string(actual), configDataFile)
82 assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
83}
84
85func TestConfigCreateWithLabels(t *testing.T) {
86 expectedLabels := map[string]string{

Callers

nothing calls this directly

Calls 4

OutBufferMethod · 0.95
newConfigCreateCommandFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…