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

Function TestNodeRemoveErrors

cli/command/node/remove_test.go:13–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestNodeRemoveErrors(t *testing.T) {
14 testCases := []struct {
15 args []string
16 nodeRemoveFunc func() (client.NodeRemoveResult, error)
17 expectedError string
18 }{
19 {
20 expectedError: "requires at least 1 argument",
21 },
22 {
23 args: []string{"nodeID"},
24 nodeRemoveFunc: func() (client.NodeRemoveResult, error) {
25 return client.NodeRemoveResult{}, errors.New("error removing the node")
26 },
27 expectedError: "error removing the node",
28 },
29 }
30 for _, tc := range testCases {
31 cmd := newRemoveCommand(
32 test.NewFakeCli(&fakeClient{
33 nodeRemoveFunc: tc.nodeRemoveFunc,
34 }))
35 cmd.SetArgs(tc.args)
36 cmd.SetOut(io.Discard)
37 cmd.SetErr(io.Discard)
38 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
39 }
40}
41
42func TestNodeRemoveMultiple(t *testing.T) {
43 cmd := newRemoveCommand(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…