(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestPluginEnableErrors(t *testing.T) { |
| 15 | testCases := []struct { |
| 16 | args []string |
| 17 | flags map[string]string |
| 18 | pluginEnableFunc func(name string, options client.PluginEnableOptions) (client.PluginEnableResult, error) |
| 19 | expectedError string |
| 20 | }{ |
| 21 | { |
| 22 | args: []string{}, |
| 23 | expectedError: "requires 1 argument", |
| 24 | }, |
| 25 | { |
| 26 | args: []string{"too-many", "arguments"}, |
| 27 | expectedError: "requires 1 argument", |
| 28 | }, |
| 29 | { |
| 30 | args: []string{"plugin-foo"}, |
| 31 | pluginEnableFunc: func(name string, options client.PluginEnableOptions) (client.PluginEnableResult, error) { |
| 32 | return client.PluginEnableResult{}, errors.New("failed to enable plugin") |
| 33 | }, |
| 34 | expectedError: "failed to enable plugin", |
| 35 | }, |
| 36 | { |
| 37 | args: []string{"plugin-foo"}, |
| 38 | flags: map[string]string{ |
| 39 | "timeout": "-1", |
| 40 | }, |
| 41 | expectedError: "negative timeout -1 is invalid", |
| 42 | }, |
| 43 | } |
| 44 | |
| 45 | for _, tc := range testCases { |
| 46 | cmd := newEnableCommand(test.NewFakeCli(&fakeClient{ |
| 47 | pluginEnableFunc: tc.pluginEnableFunc, |
| 48 | })) |
| 49 | cmd.SetArgs(tc.args) |
| 50 | for key, value := range tc.flags { |
| 51 | assert.NilError(t, cmd.Flags().Set(key, value)) |
| 52 | } |
| 53 | cmd.SetOut(io.Discard) |
| 54 | cmd.SetErr(io.Discard) |
| 55 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | func TestPluginEnable(t *testing.T) { |
| 60 | cli := test.NewFakeCli(&fakeClient{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…