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

Function TestConfigInspectWithoutFormat

cli/command/config/inspect_test.go:71–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestConfigInspectWithoutFormat(t *testing.T) {
72 testCases := []struct {
73 name string
74 args []string
75 configInspectFunc func(_ context.Context, configID string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error)
76 }{
77 {
78 name: "single-config",
79 args: []string{"foo"},
80 configInspectFunc: func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) {
81 if name != "foo" {
82 return client.ConfigInspectResult{}, fmt.Errorf("invalid name, expected %s, got %s", "foo", name)
83 }
84 return client.ConfigInspectResult{
85 Config: *builders.Config(
86 builders.ConfigID("ID-foo"),
87 builders.ConfigName("foo"),
88 ),
89 }, nil
90 },
91 },
92 {
93 name: "multiple-configs-with-labels",
94 args: []string{"foo", "bar"},
95 configInspectFunc: func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) {
96 return client.ConfigInspectResult{
97 Config: *builders.Config(
98 builders.ConfigID("ID-"+name),
99 builders.ConfigName(name),
100 builders.ConfigLabels(map[string]string{"label1": "label-foo"}),
101 ),
102 }, nil
103 },
104 },
105 }
106 for _, tc := range testCases {
107 cli := test.NewFakeCli(&fakeClient{configInspectFunc: tc.configInspectFunc})
108 cmd := newConfigInspectCommand(cli)
109 cmd.SetArgs(tc.args)
110 assert.NilError(t, cmd.Execute())
111 golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-without-format.%s.golden", tc.name))
112 }
113}
114
115func TestConfigInspectWithFormat(t *testing.T) {
116 configInspectFunc := func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) {

Callers

nothing calls this directly

Calls 4

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