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

Function TestRemoveErrors

cli/command/plugin/remove_test.go:14–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestRemoveErrors(t *testing.T) {
15 testCases := []struct {
16 args []string
17 pluginRemoveFunc func(name string, options client.PluginRemoveOptions) (client.PluginRemoveResult, error)
18 expectedError string
19 }{
20 {
21 args: []string{},
22 expectedError: "requires at least 1 argument",
23 },
24 {
25 args: []string{"plugin-foo"},
26 pluginRemoveFunc: func(name string, options client.PluginRemoveOptions) (client.PluginRemoveResult, error) {
27 return client.PluginRemoveResult{}, errors.New("error removing plugin")
28 },
29 expectedError: "error removing plugin",
30 },
31 }
32
33 for _, tc := range testCases {
34 cli := test.NewFakeCli(&fakeClient{
35 pluginRemoveFunc: tc.pluginRemoveFunc,
36 })
37 cmd := newRemoveCommand(cli)
38 cmd.SetArgs(tc.args)
39 cmd.SetOut(io.Discard)
40 cmd.SetErr(io.Discard)
41 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
42 }
43}
44
45func TestRemove(t *testing.T) {
46 cli := test.NewFakeCli(&fakeClient{})

Callers

nothing calls this directly

Calls 4

SetArgsMethod · 0.80
newRemoveCommandFunction · 0.70
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…