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

Function TestInstall

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

Source from the content-addressed store, hash-verified

57}
58
59func 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}

Callers

nothing calls this directly

Calls 5

OutBufferMethod · 0.95
newInstallCommandFunction · 0.85
SetArgsMethod · 0.80
ContainsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…