(t *testing.T)
| 156 | } |
| 157 | |
| 158 | func TestNetworkCreateWithFlags(t *testing.T) { |
| 159 | expectedDriver := "foo" |
| 160 | expectedOpts := []network.IPAMConfig{ |
| 161 | { |
| 162 | Subnet: netip.MustParsePrefix("192.168.4.0/24"), |
| 163 | IPRange: netip.MustParsePrefix("192.168.4.0/24"), |
| 164 | Gateway: netip.MustParseAddr("192.168.4.1"), // FIXME(thaJeztah): this used to accept a CIDR ("192.168.4.1/24") |
| 165 | AuxAddress: map[string]netip.Addr{}, |
| 166 | }, |
| 167 | } |
| 168 | cli := test.NewFakeCli(&fakeClient{ |
| 169 | networkCreateFunc: func(ctx context.Context, name string, options client.NetworkCreateOptions) (client.NetworkCreateResult, error) { |
| 170 | assert.Check(t, is.Equal(expectedDriver, options.Driver), "not expected driver error") |
| 171 | assert.Check(t, is.DeepEqual(expectedOpts, options.IPAM.Config, cmpopts.EquateComparable(netip.Addr{}, netip.Prefix{})), "not expected driver error") |
| 172 | return client.NetworkCreateResult{ |
| 173 | ID: name, |
| 174 | }, nil |
| 175 | }, |
| 176 | }) |
| 177 | args := []string{"banana"} |
| 178 | cmd := newCreateCommand(cli) |
| 179 | |
| 180 | cmd.SetArgs(args) |
| 181 | assert.Check(t, cmd.Flags().Set("driver", "foo")) |
| 182 | assert.Check(t, cmd.Flags().Set("ip-range", "192.168.4.0/24")) |
| 183 | assert.Check(t, cmd.Flags().Set("gateway", "192.168.4.1")) // FIXME(thaJeztah): this used to accept a CIDR ("192.168.4.1/24") |
| 184 | assert.Check(t, cmd.Flags().Set("subnet", "192.168.4.0/24")) |
| 185 | assert.NilError(t, cmd.Execute()) |
| 186 | assert.Check(t, is.Equal("banana", strings.TrimSpace(cli.OutBuffer().String()))) |
| 187 | } |
| 188 | |
| 189 | // TestNetworkCreateIPv4 verifies behavior of the "--ipv4" option. This option |
| 190 | // is an optional bool, and must default to "nil", not "true" or "false". |
nothing calls this directly
no test coverage detected
searching dependent graphs…