(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func 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, |
nothing calls this directly
no test coverage detected
searching dependent graphs…