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

Function TestPluginContextWriteJSONField

cli/command/plugin/formatter_test.go:198–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

196}
197
198func TestPluginContextWriteJSONField(t *testing.T) {
199 plugins := client.PluginListResult{
200 Items: []plugin.Plugin{
201 {ID: "pluginID1", Name: "foobar_baz"},
202 {ID: "pluginID2", Name: "foobar_bar"},
203 },
204 }
205 out := bytes.NewBufferString("")
206 err := formatWrite(formatter.Context{Format: "{{json .ID}}", Output: out}, plugins)
207 if err != nil {
208 t.Fatal(err)
209 }
210 for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
211 var s string
212 if err := json.Unmarshal([]byte(line), &s); err != nil {
213 t.Fatal(err)
214 }
215 assert.Check(t, is.Equal(plugins.Items[i].ID, s))
216 }
217}

Callers

nothing calls this directly

Calls 2

formatWriteFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…