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

Function TestNodeInspectErrors

cli/command/node/inspect_test.go:18–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestNodeInspectErrors(t *testing.T) {
19 testCases := []struct {
20 args []string
21 flags map[string]string
22 nodeInspectFunc func() (client.NodeInspectResult, error)
23 infoFunc func() (client.SystemInfoResult, error)
24 expectedError string
25 }{
26 {
27 expectedError: "requires at least 1 argument",
28 },
29 {
30 args: []string{"self"},
31 infoFunc: func() (client.SystemInfoResult, error) {
32 return client.SystemInfoResult{}, errors.New("error asking for node info")
33 },
34 expectedError: "error asking for node info",
35 },
36 {
37 args: []string{"nodeID"},
38 nodeInspectFunc: func() (client.NodeInspectResult, error) {
39 return client.NodeInspectResult{}, errors.New("error inspecting the node")
40 },
41 infoFunc: func() (client.SystemInfoResult, error) {
42 return client.SystemInfoResult{}, errors.New("error asking for node info")
43 },
44 expectedError: "error inspecting the node",
45 },
46 {
47 args: []string{"self"},
48 nodeInspectFunc: func() (client.NodeInspectResult, error) {
49 return client.NodeInspectResult{}, errors.New("error inspecting the node")
50 },
51 infoFunc: func() (client.SystemInfoResult, error) {
52 return client.SystemInfoResult{
53 Info: system.Info{
54 Swarm: swarm.Info{NodeID: "abc"},
55 },
56 }, nil
57 },
58 expectedError: "error inspecting the node",
59 },
60 {
61 args: []string{"self"},
62 flags: map[string]string{
63 "pretty": "true",
64 },
65 infoFunc: func() (client.SystemInfoResult, error) {
66 return client.SystemInfoResult{}, errors.New("error asking for node info")
67 },
68 expectedError: "error asking for node info",
69 },
70 }
71 for _, tc := range testCases {
72 cmd := newInspectCommand(
73 test.NewFakeCli(&fakeClient{
74 nodeInspectFunc: tc.nodeInspectFunc,
75 infoFunc: tc.infoFunc,

Callers

nothing calls this directly

Calls 5

SetArgsMethod · 0.80
newInspectCommandFunction · 0.70
SetMethod · 0.45
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…