(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestInstallErrors(t *testing.T) { |
| 16 | testCases := []struct { |
| 17 | description string |
| 18 | args []string |
| 19 | expectedError string |
| 20 | installFunc func(name string, options client.PluginInstallOptions) (client.PluginInstallResult, error) |
| 21 | }{ |
| 22 | { |
| 23 | description: "insufficient number of arguments", |
| 24 | args: []string{}, |
| 25 | expectedError: "requires at least 1 argument", |
| 26 | }, |
| 27 | { |
| 28 | description: "invalid alias", |
| 29 | args: []string{"foo", "--alias", "UPPERCASE_ALIAS"}, |
| 30 | expectedError: "invalid", |
| 31 | }, |
| 32 | { |
| 33 | description: "invalid plugin name", |
| 34 | args: []string{"UPPERCASE_REPO_NAME"}, |
| 35 | expectedError: "invalid", |
| 36 | }, |
| 37 | { |
| 38 | description: "installation error", |
| 39 | args: []string{"foo"}, |
| 40 | expectedError: "error installing plugin", |
| 41 | installFunc: func(name string, options client.PluginInstallOptions) (client.PluginInstallResult, error) { |
| 42 | return client.PluginInstallResult{}, errors.New("error installing plugin") |
| 43 | }, |
| 44 | }, |
| 45 | } |
| 46 | |
| 47 | for _, tc := range testCases { |
| 48 | t.Run(tc.description, func(t *testing.T) { |
| 49 | cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc}) |
| 50 | cmd := newInstallCommand(cli) |
| 51 | cmd.SetArgs(tc.args) |
| 52 | cmd.SetOut(io.Discard) |
| 53 | cmd.SetErr(io.Discard) |
| 54 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 55 | }) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | func TestInstall(t *testing.T) { |
| 60 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…