(t *testing.T)
| 74 | } |
| 75 | |
| 76 | func TestNodeUpdate(t *testing.T) { |
| 77 | testCases := []struct { |
| 78 | args []string |
| 79 | flags map[string]string |
| 80 | nodeInspectFunc func() (client.NodeInspectResult, error) |
| 81 | nodeUpdateFunc func(nodeID string, options client.NodeUpdateOptions) (client.NodeUpdateResult, error) |
| 82 | }{ |
| 83 | { |
| 84 | args: []string{"nodeID"}, |
| 85 | flags: map[string]string{ |
| 86 | "role": "manager", |
| 87 | }, |
| 88 | nodeInspectFunc: func() (client.NodeInspectResult, error) { |
| 89 | return client.NodeInspectResult{ |
| 90 | Node: *builders.Node(), |
| 91 | }, nil |
| 92 | }, |
| 93 | nodeUpdateFunc: func(nodeID string, options client.NodeUpdateOptions) (client.NodeUpdateResult, error) { |
| 94 | if options.Spec.Role != swarm.NodeRoleManager { |
| 95 | return client.NodeUpdateResult{}, errors.New("expected role manager, got " + string(options.Spec.Role)) |
| 96 | } |
| 97 | return client.NodeUpdateResult{}, nil |
| 98 | }, |
| 99 | }, |
| 100 | { |
| 101 | args: []string{"nodeID"}, |
| 102 | flags: map[string]string{ |
| 103 | "availability": "drain", |
| 104 | }, |
| 105 | nodeInspectFunc: func() (client.NodeInspectResult, error) { |
| 106 | return client.NodeInspectResult{ |
| 107 | Node: *builders.Node(), |
| 108 | }, nil |
| 109 | }, |
| 110 | nodeUpdateFunc: func(nodeID string, options client.NodeUpdateOptions) (client.NodeUpdateResult, error) { |
| 111 | if options.Spec.Availability != swarm.NodeAvailabilityDrain { |
| 112 | return client.NodeUpdateResult{}, errors.New("expected drain availability, got " + string(options.Spec.Availability)) |
| 113 | } |
| 114 | return client.NodeUpdateResult{}, nil |
| 115 | }, |
| 116 | }, |
| 117 | { |
| 118 | args: []string{"nodeID"}, |
| 119 | flags: map[string]string{ |
| 120 | "label-add": "lbl", |
| 121 | }, |
| 122 | nodeInspectFunc: func() (client.NodeInspectResult, error) { |
| 123 | return client.NodeInspectResult{ |
| 124 | Node: *builders.Node(), |
| 125 | }, nil |
| 126 | }, |
| 127 | nodeUpdateFunc: func(nodeID string, options client.NodeUpdateOptions) (client.NodeUpdateResult, error) { |
| 128 | if _, present := options.Spec.Annotations.Labels["lbl"]; !present { |
| 129 | return client.NodeUpdateResult{}, fmt.Errorf("expected 'lbl' label, got %v", options.Spec.Annotations.Labels) |
| 130 | } |
| 131 | return client.NodeUpdateResult{}, nil |
| 132 | }, |
| 133 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…