MCPcopy Index your code
hub / github.com/docker/cli / TestInstallErrors

Function TestInstallErrors

cli/command/plugin/install_test.go:15–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func 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
59func TestInstall(t *testing.T) {
60 testCases := []struct {

Callers

nothing calls this directly

Calls 4

newInstallCommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…