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

Function TestNewImagesCommandSuccess

cli/command/image/list_test.go:49–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestNewImagesCommandSuccess(t *testing.T) {
50 testCases := []struct {
51 name string
52 args []string
53 imageFormat string
54 imageListFunc func(options client.ImageListOptions) (client.ImageListResult, error)
55 }{
56 {
57 name: "simple",
58 },
59 {
60 name: "format",
61 imageFormat: "raw",
62 },
63 {
64 name: "quiet-format",
65 args: []string{"-q"},
66 imageFormat: "table",
67 },
68 {
69 name: "match-name",
70 args: []string{"image"},
71 imageListFunc: func(options client.ImageListOptions) (client.ImageListResult, error) {
72 assert.Check(t, options.Filters["reference"]["image"])
73 return client.ImageListResult{}, nil
74 },
75 },
76 {
77 name: "filters",
78 args: []string{"--filter", "name=value"},
79 imageListFunc: func(options client.ImageListOptions) (client.ImageListResult, error) {
80 assert.Check(t, options.Filters["name"]["value"])
81 return client.ImageListResult{}, nil
82 },
83 },
84 }
85 for _, tc := range testCases {
86 t.Run(tc.name, func(t *testing.T) {
87 cli := test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc})
88 cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat})
89 cmd := newImagesCommand(cli)
90 cmd.SetOut(io.Discard)
91 cmd.SetErr(io.Discard)
92 cmd.SetArgs(nilToEmptySlice(tc.args))
93 err := cmd.Execute()
94 assert.NilError(t, err)
95 golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("list-command-success.%s.golden", tc.name))
96 })
97 }
98}
99
100func TestNewListCommandAlias(t *testing.T) {
101 cmd := newListCommand(test.NewFakeCli(&fakeClient{}))

Callers

nothing calls this directly

Calls 8

SetConfigFileMethod · 0.95
OutBufferMethod · 0.95
newImagesCommandFunction · 0.85
nilToEmptySliceFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…