|
8 | 8 |
|
9 | 9 | "github.com/linode/linodego" |
10 | 10 | . "github.com/linode/linodego" |
| 11 | + "github.com/stretchr/testify/assert" |
11 | 12 | ) |
12 | 13 |
|
13 | 14 | const ( |
@@ -153,35 +154,6 @@ func createVPCWithDualStackSubnet(t *testing.T, client *linodego.Client, vpcModi |
153 | 154 | return vpc, &vpc.Subnets[0], teardown, err |
154 | 155 | } |
155 | 156 |
|
156 | | -func createSubnetInVPC( |
157 | | - t *testing.T, |
158 | | - client *linodego.Client, |
159 | | - vpc linodego.VPC, |
160 | | - vpcModifier ...vpcModifier, |
161 | | -) ( |
162 | | - *linodego.VPCSubnet, |
163 | | - func(), |
164 | | - error, |
165 | | -) { |
166 | | - t.Helper() |
167 | | - createOpts := linodego.VPCSubnetCreateOptions{ |
168 | | - Label: "linodego-vpc-test-" + getUniqueText(), |
169 | | - IPv4: TestSubnetIPv4, |
170 | | - } |
171 | | - vpcSubnet, err := client.CreateVPCSubnet(context.Background(), createOpts, vpc.ID) |
172 | | - if err != nil { |
173 | | - t.Fatal(formatVPCSubnetError(err, "creating", &vpc.ID, nil)) |
174 | | - } |
175 | | - |
176 | | - teardown := func() { |
177 | | - err = client.DeleteVPCSubnet(context.Background(), vpc.ID, vpcSubnet.ID) |
178 | | - if err != nil { |
179 | | - t.Error(formatVPCSubnetError(err, "deleting", &vpc.ID, &vpcSubnet.ID)) |
180 | | - } |
181 | | - } |
182 | | - return vpcSubnet, teardown, err |
183 | | -} |
184 | | - |
185 | 157 | func setupVPCWithSubnet( |
186 | 158 | t *testing.T, |
187 | 159 | fixturesYaml string, |
@@ -376,3 +348,20 @@ func TestVPC_Subnet_WithInstance(t *testing.T) { |
376 | 348 | t.Fatalf("nat_1_1 subnet IP mismatch") |
377 | 349 | } |
378 | 350 | } |
| 351 | + |
| 352 | +func TestVPC_Subnet_WithNodeBalancer(t *testing.T) { |
| 353 | + client, vpc, vpcSubnet, teardown := setupNodebalancer(t, "fixtures/TestVPC_Subnet_WithNodeBalancer") |
| 354 | + |
| 355 | + defer teardown() |
| 356 | + |
| 357 | + refreshedSubnet, err := client.GetVPCSubnet(context.Background(), vpc.ID, vpcSubnet.ID) |
| 358 | + if err != nil { |
| 359 | + t.Fatal(err) |
| 360 | + } |
| 361 | + |
| 362 | + assert.Equal(t, 0, len(refreshedSubnet.Linodes), "expected no linode") |
| 363 | + assert.Equal(t, 1, len(refreshedSubnet.Nodebalancers), "expected 1 assigned node balancer") |
| 364 | + assert.Equal(t, "192.168.0.64/30", refreshedSubnet.Nodebalancers[0].Ipv4Range, "expected matching ipv4 range") |
| 365 | + assert.Equal(t, 0, len(refreshedSubnet.Nodebalancers[0].Ipv6Ranges), "expected 0 ipv6 ranges") |
| 366 | + |
| 367 | +} |
0 commit comments