Skip to content

Commit 83efc97

Browse files
committed
remove packngo from tests, too
1 parent 38fff66 commit 83efc97

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

internal/resources/metal/vlan/datasource_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package vlan_test
22

33
import (
4+
"context"
45
"fmt"
56
"reflect"
67
"testing"
@@ -278,13 +279,13 @@ func TestMetalVlan_matchingVlan(t *testing.T) {
278279
}
279280

280281
func testAccMetalDatasourceVlanCheckDestroyed(s *terraform.State) error {
281-
client := acceptance.TestAccProvider.Meta().(*config.Config).Metal
282+
client := acceptance.TestAccProvider.Meta().(*config.Config).NewMetalClientForTesting()
282283

283284
for _, rs := range s.RootModule().Resources {
284285
if rs.Type != "equinix_metal_vlan" {
285286
continue
286287
}
287-
if _, _, err := client.ProjectVirtualNetworks.Get(rs.Primary.ID, nil); err == nil {
288+
if _, _, err := client.VLANsApi.GetVirtualNetwork(context.Background(), rs.Primary.ID).Execute(); err == nil {
288289
return fmt.Errorf("Data source VLAN still exists")
289290
}
290291
}

internal/resources/metal/vlan/resource_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package vlan_test
22

33
import (
4+
"context"
45
"fmt"
56
"strings"
67
"testing"
78

9+
"github.com/equinix/equinix-sdk-go/services/metalv1"
810
"github.com/equinix/terraform-provider-equinix/internal/acceptance"
911
"github.com/equinix/terraform-provider-equinix/internal/config"
1012
"github.com/hashicorp/terraform-plugin-testing/plancheck"
1113

1214
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1315
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1416
"github.com/hashicorp/terraform-plugin-testing/terraform"
15-
"github.com/packethost/packngo"
1617
)
1718

1819
func testAccCheckMetalVlanConfig_metro(projSuffix, metro, desc string) string {
@@ -56,7 +57,7 @@ resource "equinix_metal_vlan" "foovlan" {
5657
}
5758

5859
func TestAccMetalVlan_metro(t *testing.T) {
59-
var vlan packngo.VirtualNetwork
60+
var vlan metalv1.VirtualNetwork
6061
rs := acctest.RandString(10)
6162
lowerSiliconValley := "sv"
6263
upperDallas := "DA"
@@ -109,7 +110,7 @@ func TestAccMetalVlan_metro(t *testing.T) {
109110
}
110111

111112
func TestAccMetalVlan_NoDescription(t *testing.T) {
112-
var vlan packngo.VirtualNetwork
113+
var vlan metalv1.VirtualNetwork
113114
rs := acctest.RandString(10)
114115
metro := "sv"
115116

@@ -134,7 +135,7 @@ func TestAccMetalVlan_NoDescription(t *testing.T) {
134135
}
135136

136137
func TestAccMetalVlan_RemoveDescription(t *testing.T) {
137-
var vlan packngo.VirtualNetwork
138+
var vlan metalv1.VirtualNetwork
138139
rs := acctest.RandString(10)
139140
metro := "sv"
140141

@@ -168,7 +169,7 @@ func TestAccMetalVlan_RemoveDescription(t *testing.T) {
168169
})
169170
}
170171

171-
func testAccCheckMetalVlanExists(n string, vlan *packngo.VirtualNetwork) resource.TestCheckFunc {
172+
func testAccCheckMetalVlanExists(n string, vlan *metalv1.VirtualNetwork) resource.TestCheckFunc {
172173
return func(s *terraform.State) error {
173174
rs, ok := s.RootModule().Resources[n]
174175
if !ok {
@@ -178,13 +179,13 @@ func testAccCheckMetalVlanExists(n string, vlan *packngo.VirtualNetwork) resourc
178179
return fmt.Errorf("No Record ID is set")
179180
}
180181

181-
client := acceptance.TestAccProvider.Meta().(*config.Config).Metal
182+
client := acceptance.TestAccProvider.Meta().(*config.Config).NewMetalClientForTesting()
182183

183-
foundVlan, _, err := client.ProjectVirtualNetworks.Get(rs.Primary.ID, nil)
184+
foundVlan, _, err := client.VLANsApi.GetVirtualNetwork(context.Background(), rs.Primary.ID).Execute()
184185
if err != nil {
185186
return err
186187
}
187-
if foundVlan.ID != rs.Primary.ID {
188+
if foundVlan.GetId() != rs.Primary.ID {
188189
return fmt.Errorf("Record not found: %v - %v", rs.Primary.ID, foundVlan)
189190
}
190191

@@ -232,7 +233,7 @@ func TestAccMetalVlan_importBasic(t *testing.T) {
232233
}
233234

234235
func TestAccMetalVlan_facility_to_metro(t *testing.T) {
235-
var vlan packngo.VirtualNetwork
236+
var vlan metalv1.VirtualNetwork
236237
rs := acctest.RandString(10)
237238
metro := "sv"
238239
facility := "sv15"
@@ -273,7 +274,7 @@ func TestAccMetalVlan_facility_to_metro(t *testing.T) {
273274
}
274275

275276
func TestAccMetalVlan_metro_upgradeFromVersion(t *testing.T) {
276-
var vlan packngo.VirtualNetwork
277+
var vlan metalv1.VirtualNetwork
277278
rs := acctest.RandString(10)
278279
metro := "sv"
279280

@@ -311,7 +312,7 @@ func TestAccMetalVlan_metro_upgradeFromVersion(t *testing.T) {
311312
}
312313

313314
func TestAccMetalVlan_metro_suppress_diff(t *testing.T) {
314-
var vlan packngo.VirtualNetwork
315+
var vlan metalv1.VirtualNetwork
315316
rs := acctest.RandString(10)
316317
metro := "sv"
317318

0 commit comments

Comments
 (0)