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

Function TestListJSON

cli/command/context/list_test.go:40–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestListJSON(t *testing.T) {
41 cli := makeFakeCli(t)
42 createTestContext(t, cli, "current", nil)
43 createTestContext(t, cli, "context1", map[string]any{"Type": "aci"})
44 createTestContext(t, cli, "context2", map[string]any{"Type": "ecs"})
45 createTestContext(t, cli, "context3", map[string]any{"Type": "moby"})
46 cli.SetCurrentContext("current")
47
48 t.Run("format={{json .}}", func(t *testing.T) {
49 cli.OutBuffer().Reset()
50 assert.NilError(t, runList(cli, &listOptions{format: formatter.JSONFormat}))
51 golden.Assert(t, cli.OutBuffer().String(), "list-json.golden")
52 })
53
54 t.Run("format=json", func(t *testing.T) {
55 cli.OutBuffer().Reset()
56 assert.NilError(t, runList(cli, &listOptions{format: formatter.JSONFormatKey}))
57 golden.Assert(t, cli.OutBuffer().String(), "list-json.golden")
58 })
59
60 t.Run("format={{ json .Name }}", func(t *testing.T) {
61 cli.OutBuffer().Reset()
62 assert.NilError(t, runList(cli, &listOptions{format: `{{ json .Name }}`}))
63 golden.Assert(t, cli.OutBuffer().String(), "list-json-name.golden")
64 })
65}
66
67func TestListQuiet(t *testing.T) {
68 cli := makeFakeCli(t)

Callers

nothing calls this directly

Calls 6

makeFakeCliFunction · 0.85
createTestContextFunction · 0.85
SetCurrentContextMethod · 0.80
runListFunction · 0.70
StringMethod · 0.65
OutBufferMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…