(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestNodeDemoteErrors(t *testing.T) { |
| 16 | testCases := []struct { |
| 17 | args []string |
| 18 | nodeInspectFunc func() (client.NodeInspectResult, error) |
| 19 | nodeUpdateFunc func(nodeID string, options client.NodeUpdateOptions) (client.NodeUpdateResult, error) |
| 20 | expectedError string |
| 21 | }{ |
| 22 | { |
| 23 | expectedError: "requires at least 1 argument", |
| 24 | }, |
| 25 | { |
| 26 | args: []string{"nodeID"}, |
| 27 | nodeInspectFunc: func() (client.NodeInspectResult, error) { |
| 28 | return client.NodeInspectResult{}, errors.New("error inspecting the node") |
| 29 | }, |
| 30 | expectedError: "error inspecting the node", |
| 31 | }, |
| 32 | { |
| 33 | args: []string{"nodeID"}, |
| 34 | nodeUpdateFunc: func(nodeID string, options client.NodeUpdateOptions) (client.NodeUpdateResult, error) { |
| 35 | return client.NodeUpdateResult{}, errors.New("error updating the node") |
| 36 | }, |
| 37 | expectedError: "error updating the node", |
| 38 | }, |
| 39 | } |
| 40 | for _, tc := range testCases { |
| 41 | cmd := newDemoteCommand( |
| 42 | test.NewFakeCli(&fakeClient{ |
| 43 | nodeInspectFunc: tc.nodeInspectFunc, |
| 44 | nodeUpdateFunc: tc.nodeUpdateFunc, |
| 45 | })) |
| 46 | cmd.SetArgs(tc.args) |
| 47 | cmd.SetOut(io.Discard) |
| 48 | cmd.SetErr(io.Discard) |
| 49 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func TestNodeDemoteNoChange(t *testing.T) { |
| 54 | cmd := newDemoteCommand( |
nothing calls this directly
no test coverage detected
searching dependent graphs…