(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestNetworkCreateErrors(t *testing.T) { |
| 20 | testCases := []struct { |
| 21 | args []string |
| 22 | flags map[string]string |
| 23 | networkCreateFunc func(ctx context.Context, name string, options client.NetworkCreateOptions) (client.NetworkCreateResult, error) |
| 24 | expectedError string |
| 25 | }{ |
| 26 | { |
| 27 | expectedError: "1 argument", |
| 28 | }, |
| 29 | { |
| 30 | args: []string{"toto"}, |
| 31 | networkCreateFunc: func(ctx context.Context, name string, createBody client.NetworkCreateOptions) (client.NetworkCreateResult, error) { |
| 32 | return client.NetworkCreateResult{}, errors.New("error creating network") |
| 33 | }, |
| 34 | expectedError: "error creating network", |
| 35 | }, |
| 36 | { |
| 37 | args: []string{"toto"}, |
| 38 | flags: map[string]string{ |
| 39 | "ip-range": "255.255.0.0/24", |
| 40 | "gateway": "255.0.255.0", // FIXME(thaJeztah): this used to accept a CIDR ("255.0.255.0/24") |
| 41 | "subnet": "10.1.2.0.30.50", |
| 42 | }, |
| 43 | expectedError: `netip.ParsePrefix("10.1.2.0.30.50"): no '/'`, |
| 44 | }, |
| 45 | { |
| 46 | args: []string{"toto"}, |
| 47 | flags: map[string]string{ |
| 48 | "gateway": "255.0.0.0", // FIXME(thaJeztah): this used to accept a CIDR ("255.0.0.0/24") |
| 49 | }, |
| 50 | expectedError: "every ip-range or gateway must have a corresponding subnet", |
| 51 | }, |
| 52 | { |
| 53 | args: []string{"toto"}, |
| 54 | flags: map[string]string{ |
| 55 | "ip-range": "255.0.0.0/24", |
| 56 | }, |
| 57 | expectedError: "every ip-range or gateway must have a corresponding subnet", |
| 58 | }, |
| 59 | { |
| 60 | args: []string{"toto"}, |
| 61 | flags: map[string]string{ |
| 62 | "ip-range": "255.0.0.0/24", |
| 63 | "gateway": "255.0.0.0", // FIXME(thaJeztah): this used to accept a CIDR ("255.0.0.0/24") |
| 64 | }, |
| 65 | expectedError: "every ip-range or gateway must have a corresponding subnet", |
| 66 | }, |
| 67 | { |
| 68 | args: []string{"toto"}, |
| 69 | flags: map[string]string{ |
| 70 | "ip-range": "255.255.0.0/24", |
| 71 | "gateway": "255.0.255.0", // FIXME(thaJeztah): this used to accept a CIDR ("255.0.0.0/24") |
| 72 | "subnet": "10.1.2.0/23,10.1.3.248/30", |
| 73 | }, |
| 74 | expectedError: "multiple overlapping subnet configuration is not supported", |
| 75 | }, |
| 76 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…