(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func 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 | |
| 49 | func TestNewImagesCommandSuccess(t *testing.T) { |
| 50 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…