(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func TestNetworkConnectWithFlags(t *testing.T) { |
| 50 | expectedConfig := &network.EndpointSettings{ |
| 51 | IPAMConfig: &network.EndpointIPAMConfig{ |
| 52 | IPv4Address: netip.MustParseAddr("192.168.4.1"), |
| 53 | IPv6Address: netip.MustParseAddr("fdef:f401:8da0:1234::5678"), |
| 54 | LinkLocalIPs: []netip.Addr{netip.MustParseAddr("169.254.42.42")}, |
| 55 | }, |
| 56 | Links: []string{"otherctr"}, |
| 57 | Aliases: []string{"poor-yorick"}, |
| 58 | DriverOpts: map[string]string{ |
| 59 | "driveropt1": "optval1,optval2", |
| 60 | "driveropt2": "optval4", |
| 61 | }, |
| 62 | GwPriority: 100, |
| 63 | } |
| 64 | cli := test.NewFakeCli(&fakeClient{ |
| 65 | networkConnectFunc: func(ctx context.Context, networkID string, options client.NetworkConnectOptions) (client.NetworkConnectResult, error) { |
| 66 | assert.Check(t, is.DeepEqual(expectedConfig, options.EndpointConfig, cmpopts.EquateComparable(netip.Addr{}))) |
| 67 | return client.NetworkConnectResult{}, nil |
| 68 | }, |
| 69 | }) |
| 70 | args := []string{"mynet", "myctr"} |
| 71 | cmd := newConnectCommand(cli) |
| 72 | |
| 73 | cmd.SetArgs(args) |
| 74 | for _, opt := range []struct{ name, value string }{ |
| 75 | {"alias", "poor-yorick"}, |
| 76 | {"driver-opt", "\"driveropt1=optval1,optval2\""}, |
| 77 | {"driver-opt", "driveropt2=optval3"}, |
| 78 | {"driver-opt", "driveropt2=optval4"}, // replaces value |
| 79 | {"ip", "192.168.4.1"}, |
| 80 | {"ip6", "fdef:f401:8da0:1234::5678"}, |
| 81 | {"link", "otherctr"}, |
| 82 | {"link-local-ip", "169.254.42.42"}, |
| 83 | {"gw-priority", "100"}, |
| 84 | } { |
| 85 | err := cmd.Flags().Set(opt.name, opt.value) |
| 86 | assert.Check(t, err) |
| 87 | } |
| 88 | assert.NilError(t, cmd.Execute()) |
| 89 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…