(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func 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 | |
| 67 | func TestListQuiet(t *testing.T) { |
| 68 | cli := makeFakeCli(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…