(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestRemoveErrors(t *testing.T) { |
| 15 | testCases := []struct { |
| 16 | args []string |
| 17 | pluginRemoveFunc func(name string, options client.PluginRemoveOptions) (client.PluginRemoveResult, error) |
| 18 | expectedError string |
| 19 | }{ |
| 20 | { |
| 21 | args: []string{}, |
| 22 | expectedError: "requires at least 1 argument", |
| 23 | }, |
| 24 | { |
| 25 | args: []string{"plugin-foo"}, |
| 26 | pluginRemoveFunc: func(name string, options client.PluginRemoveOptions) (client.PluginRemoveResult, error) { |
| 27 | return client.PluginRemoveResult{}, errors.New("error removing plugin") |
| 28 | }, |
| 29 | expectedError: "error removing plugin", |
| 30 | }, |
| 31 | } |
| 32 | |
| 33 | for _, tc := range testCases { |
| 34 | cli := test.NewFakeCli(&fakeClient{ |
| 35 | pluginRemoveFunc: tc.pluginRemoveFunc, |
| 36 | }) |
| 37 | cmd := newRemoveCommand(cli) |
| 38 | cmd.SetArgs(tc.args) |
| 39 | cmd.SetOut(io.Discard) |
| 40 | cmd.SetErr(io.Discard) |
| 41 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | func TestRemove(t *testing.T) { |
| 46 | cli := test.NewFakeCli(&fakeClient{}) |
nothing calls this directly
no test coverage detected
searching dependent graphs…