(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestNewPruneCommandErrors(t *testing.T) { |
| 20 | testCases := []struct { |
| 21 | name string |
| 22 | args []string |
| 23 | expectedError string |
| 24 | imagePruneFunc func(client.ImagePruneOptions) (client.ImagePruneResult, error) |
| 25 | }{ |
| 26 | { |
| 27 | name: "wrong-args", |
| 28 | args: []string{"something"}, |
| 29 | expectedError: "accepts no arguments", |
| 30 | }, |
| 31 | { |
| 32 | name: "prune-error", |
| 33 | args: []string{"--force"}, |
| 34 | expectedError: "something went wrong", |
| 35 | imagePruneFunc: func(client.ImagePruneOptions) (client.ImagePruneResult, error) { |
| 36 | return client.ImagePruneResult{}, errors.New("something went wrong") |
| 37 | }, |
| 38 | }, |
| 39 | } |
| 40 | for _, tc := range testCases { |
| 41 | t.Run(tc.name, func(t *testing.T) { |
| 42 | cmd := newPruneCommand(test.NewFakeCli(&fakeClient{ |
| 43 | imagePruneFunc: tc.imagePruneFunc, |
| 44 | })) |
| 45 | cmd.SetOut(io.Discard) |
| 46 | cmd.SetErr(io.Discard) |
| 47 | cmd.SetArgs(tc.args) |
| 48 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 49 | }) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func TestNewPruneCommandSuccess(t *testing.T) { |
| 54 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…