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

Function TestNodePsErrors

cli/command/node/ps_test.go:19–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestNodePsErrors(t *testing.T) {
20 testCases := []struct {
21 args []string
22 flags map[string]string
23 infoFunc func() (client.SystemInfoResult, error)
24 nodeInspectFunc func() (client.NodeInspectResult, error)
25 taskListFunc func(options client.TaskListOptions) (client.TaskListResult, error)
26 expectedError string
27 }{
28 {
29 infoFunc: func() (client.SystemInfoResult, error) {
30 return client.SystemInfoResult{}, errors.New("error asking for node info")
31 },
32 expectedError: "error asking for node info",
33 },
34 {
35 args: []string{"nodeID"},
36 nodeInspectFunc: func() (client.NodeInspectResult, error) {
37 return client.NodeInspectResult{}, errors.New("error inspecting the node")
38 },
39 expectedError: "error inspecting the node",
40 },
41 {
42 args: []string{"nodeID"},
43 taskListFunc: func(options client.TaskListOptions) (client.TaskListResult, error) {
44 return client.TaskListResult{}, errors.New("error returning the task list")
45 },
46 expectedError: "error returning the task list",
47 },
48 }
49 for _, tc := range testCases {
50 cli := test.NewFakeCli(&fakeClient{
51 infoFunc: tc.infoFunc,
52 nodeInspectFunc: tc.nodeInspectFunc,
53 taskListFunc: tc.taskListFunc,
54 })
55 cmd := newPsCommand(cli)
56 cmd.SetArgs(tc.args)
57 for key, value := range tc.flags {
58 assert.Check(t, cmd.Flags().Set(key, value))
59 }
60 cmd.SetOut(io.Discard)
61 cmd.SetErr(io.Discard)
62 assert.Error(t, cmd.Execute(), tc.expectedError)
63 }
64}
65
66func TestNodePs(t *testing.T) {
67 testCases := []struct {

Callers

nothing calls this directly

Calls 6

SetArgsMethod · 0.80
newPsCommandFunction · 0.70
SetMethod · 0.45
SetOutMethod · 0.45
SetErrMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…