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

Function TestConfigInspectWithFormat

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

Source from the content-addressed store, hash-verified

113}
114
115func TestConfigInspectWithFormat(t *testing.T) {
116 configInspectFunc := func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) {
117 return client.ConfigInspectResult{
118 Config: *builders.Config(
119 builders.ConfigName("foo"),
120 builders.ConfigLabels(map[string]string{"label1": "label-foo"}),
121 ),
122 }, nil
123 }
124 testCases := []struct {
125 name string
126 format string
127 args []string
128 configInspectFunc func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error)
129 }{
130 {
131 name: "simple-template",
132 format: "{{.Spec.Name}}",
133 args: []string{"foo"},
134 configInspectFunc: configInspectFunc,
135 },
136 {
137 name: "json-template",
138 format: "{{json .Spec.Labels}}",
139 args: []string{"foo"},
140 configInspectFunc: configInspectFunc,
141 },
142 }
143 for _, tc := range testCases {
144 cli := test.NewFakeCli(&fakeClient{
145 configInspectFunc: tc.configInspectFunc,
146 })
147 cmd := newConfigInspectCommand(cli)
148 cmd.SetArgs(tc.args)
149 assert.Check(t, cmd.Flags().Set("format", tc.format))
150 assert.NilError(t, cmd.Execute())
151 golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-with-format.%s.golden", tc.name))
152 }
153}
154
155func TestConfigInspectPretty(t *testing.T) {
156 testCases := []struct {

Callers

nothing calls this directly

Calls 5

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