(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestInstall(t *testing.T) { |
| 60 | testCases := []struct { |
| 61 | description string |
| 62 | args []string |
| 63 | expectedOutput string |
| 64 | installFunc func(name string, options client.PluginInstallOptions) (client.PluginInstallResult, error) |
| 65 | }{ |
| 66 | { |
| 67 | description: "install with no additional flags", |
| 68 | args: []string{"foo"}, |
| 69 | expectedOutput: "Installed plugin foo\n", |
| 70 | installFunc: func(name string, options client.PluginInstallOptions) (client.PluginInstallResult, error) { |
| 71 | return client.PluginInstallResult{ReadCloser: io.NopCloser(strings.NewReader(""))}, nil |
| 72 | }, |
| 73 | }, |
| 74 | { |
| 75 | description: "install with disable flag", |
| 76 | args: []string{"--disable", "foo"}, |
| 77 | expectedOutput: "Installed plugin foo\n", |
| 78 | installFunc: func(name string, options client.PluginInstallOptions) (client.PluginInstallResult, error) { |
| 79 | assert.Check(t, options.Disabled) |
| 80 | return client.PluginInstallResult{ReadCloser: io.NopCloser(strings.NewReader(""))}, nil |
| 81 | }, |
| 82 | }, |
| 83 | } |
| 84 | |
| 85 | for _, tc := range testCases { |
| 86 | t.Run(tc.description, func(t *testing.T) { |
| 87 | cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc}) |
| 88 | cmd := newInstallCommand(cli) |
| 89 | cmd.SetArgs(tc.args) |
| 90 | assert.NilError(t, cmd.Execute()) |
| 91 | assert.Check(t, strings.Contains(cli.OutBuffer().String(), tc.expectedOutput)) |
| 92 | }) |
| 93 | } |
| 94 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…