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

Function TestNewImagesCommandErrors

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

Source from the content-addressed store, hash-verified

16)
17
18func TestNewImagesCommandErrors(t *testing.T) {
19 testCases := []struct {
20 name string
21 args []string
22 expectedError string
23 imageListFunc func(options client.ImageListOptions) (client.ImageListResult, error)
24 }{
25 {
26 name: "wrong-args",
27 args: []string{"arg1", "arg2"},
28 expectedError: "requires at most 1 argument",
29 },
30 {
31 name: "failed-list",
32 expectedError: "something went wrong",
33 imageListFunc: func(options client.ImageListOptions) (client.ImageListResult, error) {
34 return client.ImageListResult{}, errors.New("something went wrong")
35 },
36 },
37 }
38 for _, tc := range testCases {
39 t.Run(tc.name, func(t *testing.T) {
40 cmd := newImagesCommand(test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc}))
41 cmd.SetOut(io.Discard)
42 cmd.SetErr(io.Discard)
43 cmd.SetArgs(nilToEmptySlice(tc.args))
44 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
45 })
46 }
47}
48
49func TestNewImagesCommandSuccess(t *testing.T) {
50 testCases := []struct {

Callers

nothing calls this directly

Calls 5

newImagesCommandFunction · 0.85
nilToEmptySliceFunction · 0.85
SetArgsMethod · 0.80
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…