(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestNetworkConnectErrors(t *testing.T) { |
| 19 | testCases := []struct { |
| 20 | args []string |
| 21 | networkConnectFunc func(ctx context.Context, networkID string, options client.NetworkConnectOptions) (client.NetworkConnectResult, error) |
| 22 | expectedError string |
| 23 | }{ |
| 24 | { |
| 25 | expectedError: "requires 2 arguments", |
| 26 | }, |
| 27 | { |
| 28 | args: []string{"toto", "titi"}, |
| 29 | networkConnectFunc: func(ctx context.Context, networkID string, options client.NetworkConnectOptions) (client.NetworkConnectResult, error) { |
| 30 | return client.NetworkConnectResult{}, errors.New("error connecting network") |
| 31 | }, |
| 32 | expectedError: "error connecting network", |
| 33 | }, |
| 34 | } |
| 35 | |
| 36 | for _, tc := range testCases { |
| 37 | cmd := newConnectCommand( |
| 38 | test.NewFakeCli(&fakeClient{ |
| 39 | networkConnectFunc: tc.networkConnectFunc, |
| 40 | }), |
| 41 | ) |
| 42 | cmd.SetArgs(tc.args) |
| 43 | cmd.SetOut(io.Discard) |
| 44 | cmd.SetErr(io.Discard) |
| 45 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestNetworkConnectWithFlags(t *testing.T) { |
| 50 | expectedConfig := &network.EndpointSettings{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…