| 109 | } |
| 110 | |
| 111 | func TestSwarmJoinToken(t *testing.T) { |
| 112 | testCases := []struct { |
| 113 | name string |
| 114 | args []string |
| 115 | flags map[string]string |
| 116 | infoFunc func() (system.Info, error) |
| 117 | swarmInspectFunc func() (client.SwarmInspectResult, error) |
| 118 | nodeInspectFunc func() (client.NodeInspectResult, error) |
| 119 | }{ |
| 120 | { |
| 121 | name: "worker", |
| 122 | args: []string{"worker"}, |
| 123 | infoFunc: func() (system.Info, error) { |
| 124 | return system.Info{ |
| 125 | Swarm: swarm.Info{ |
| 126 | NodeID: "nodeID", |
| 127 | }, |
| 128 | }, nil |
| 129 | }, |
| 130 | nodeInspectFunc: func() (client.NodeInspectResult, error) { |
| 131 | return client.NodeInspectResult{ |
| 132 | Node: *builders.Node(builders.Manager()), |
| 133 | }, nil |
| 134 | }, |
| 135 | swarmInspectFunc: func() (client.SwarmInspectResult, error) { |
| 136 | return client.SwarmInspectResult{ |
| 137 | Swarm: *builders.Swarm(), |
| 138 | }, nil |
| 139 | }, |
| 140 | }, |
| 141 | { |
| 142 | name: "manager", |
| 143 | args: []string{"manager"}, |
| 144 | infoFunc: func() (system.Info, error) { |
| 145 | return system.Info{ |
| 146 | Swarm: swarm.Info{ |
| 147 | NodeID: "nodeID", |
| 148 | }, |
| 149 | }, nil |
| 150 | }, |
| 151 | nodeInspectFunc: func() (client.NodeInspectResult, error) { |
| 152 | return client.NodeInspectResult{ |
| 153 | Node: *builders.Node(builders.Manager()), |
| 154 | }, nil |
| 155 | }, |
| 156 | swarmInspectFunc: func() (client.SwarmInspectResult, error) { |
| 157 | return client.SwarmInspectResult{ |
| 158 | Swarm: *builders.Swarm(), |
| 159 | }, nil |
| 160 | }, |
| 161 | }, |
| 162 | { |
| 163 | name: "manager-rotate", |
| 164 | args: []string{"manager"}, |
| 165 | flags: map[string]string{ |
| 166 | flagRotate: "true", |
| 167 | }, |
| 168 | infoFunc: func() (system.Info, error) { |