(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestSwarmJoinTokenErrors(t *testing.T) { |
| 19 | testCases := []struct { |
| 20 | name string |
| 21 | args []string |
| 22 | flags map[string]string |
| 23 | infoFunc func() (system.Info, error) |
| 24 | swarmInspectFunc func() (client.SwarmInspectResult, error) |
| 25 | swarmUpdateFunc func(client.SwarmUpdateOptions) (client.SwarmUpdateResult, error) |
| 26 | nodeInspectFunc func() (client.NodeInspectResult, error) |
| 27 | expectedError string |
| 28 | }{ |
| 29 | { |
| 30 | name: "not-enough-args", |
| 31 | args: []string{}, |
| 32 | expectedError: "requires 1 argument", |
| 33 | }, |
| 34 | { |
| 35 | name: "too-many-args", |
| 36 | args: []string{"worker", "manager"}, |
| 37 | expectedError: "requires 1 argument", |
| 38 | }, |
| 39 | { |
| 40 | name: "invalid-args", |
| 41 | args: []string{"foo"}, |
| 42 | expectedError: "unknown role foo", |
| 43 | }, |
| 44 | { |
| 45 | name: "swarm-inspect-failed", |
| 46 | args: []string{"worker"}, |
| 47 | swarmInspectFunc: func() (client.SwarmInspectResult, error) { |
| 48 | return client.SwarmInspectResult{}, errors.New("error inspecting the swarm") |
| 49 | }, |
| 50 | expectedError: "error inspecting the swarm", |
| 51 | }, |
| 52 | { |
| 53 | name: "swarm-inspect-rotate-failed", |
| 54 | args: []string{"worker"}, |
| 55 | flags: map[string]string{ |
| 56 | flagRotate: "true", |
| 57 | }, |
| 58 | swarmInspectFunc: func() (client.SwarmInspectResult, error) { |
| 59 | return client.SwarmInspectResult{}, errors.New("error inspecting the swarm") |
| 60 | }, |
| 61 | expectedError: "error inspecting the swarm", |
| 62 | }, |
| 63 | { |
| 64 | name: "swarm-update-failed", |
| 65 | args: []string{"worker"}, |
| 66 | flags: map[string]string{ |
| 67 | flagRotate: "true", |
| 68 | }, |
| 69 | swarmUpdateFunc: func(client.SwarmUpdateOptions) (client.SwarmUpdateResult, error) { |
| 70 | return client.SwarmUpdateResult{}, errors.New("error updating the swarm") |
| 71 | }, |
| 72 | expectedError: "error updating the swarm", |
| 73 | }, |
| 74 | { |
| 75 | name: "node-inspect-failed", |
nothing calls this directly
no test coverage detected
searching dependent graphs…