Skip to content

Commit

Permalink
remove packngo from tests, too
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Oct 23, 2024
1 parent f1df81f commit 5b5800d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions internal/resources/metal/vlan/datasource_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vlan_test

import (
"context"
"fmt"
"reflect"
"testing"
Expand Down Expand Up @@ -278,13 +279,13 @@ func TestMetalVlan_matchingVlan(t *testing.T) {
}

func testAccMetalDatasourceVlanCheckDestroyed(s *terraform.State) error {
client := acceptance.TestAccProvider.Meta().(*config.Config).Metal
client := acceptance.TestAccProvider.Meta().(*config.Config).NewMetalClientForTesting()

for _, rs := range s.RootModule().Resources {
if rs.Type != "equinix_metal_vlan" {
continue
}
if _, _, err := client.ProjectVirtualNetworks.Get(rs.Primary.ID, nil); err == nil {
if _, _, err := client.VLANsApi.GetVirtualNetwork(context.Background(), rs.Primary.ID).Execute(); err == nil {
return fmt.Errorf("Data source VLAN still exists")
}
}
Expand Down
23 changes: 12 additions & 11 deletions internal/resources/metal/vlan/resource_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package vlan_test

import (
"context"
"fmt"
"strings"
"testing"

"github.com/equinix/equinix-sdk-go/services/metalv1"
"github.com/equinix/terraform-provider-equinix/internal/acceptance"
"github.com/equinix/terraform-provider-equinix/internal/config"
"github.com/hashicorp/terraform-plugin-testing/plancheck"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/packethost/packngo"
)

func testAccCheckMetalVlanConfig_metro(projSuffix, metro, desc string) string {
Expand Down Expand Up @@ -56,7 +57,7 @@ resource "equinix_metal_vlan" "foovlan" {
}

func TestAccMetalVlan_metro(t *testing.T) {
var vlan packngo.VirtualNetwork
var vlan metalv1.VirtualNetwork
rs := acctest.RandString(10)
lowerSiliconValley := "sv"
upperDallas := "DA"
Expand Down Expand Up @@ -109,7 +110,7 @@ func TestAccMetalVlan_metro(t *testing.T) {
}

func TestAccMetalVlan_NoDescription(t *testing.T) {
var vlan packngo.VirtualNetwork
var vlan metalv1.VirtualNetwork
rs := acctest.RandString(10)
metro := "sv"

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

func TestAccMetalVlan_RemoveDescription(t *testing.T) {
var vlan packngo.VirtualNetwork
var vlan metalv1.VirtualNetwork
rs := acctest.RandString(10)
metro := "sv"

Expand Down Expand Up @@ -168,7 +169,7 @@ func TestAccMetalVlan_RemoveDescription(t *testing.T) {
})
}

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

client := acceptance.TestAccProvider.Meta().(*config.Config).Metal
client := acceptance.TestAccProvider.Meta().(*config.Config).NewMetalClientForTesting()

foundVlan, _, err := client.ProjectVirtualNetworks.Get(rs.Primary.ID, nil)
foundVlan, _, err := client.VLANsApi.GetVirtualNetwork(context.Background(), rs.Primary.ID).Execute()
if err != nil {
return err
}
if foundVlan.ID != rs.Primary.ID {
if foundVlan.GetId() != rs.Primary.ID {
return fmt.Errorf("Record not found: %v - %v", rs.Primary.ID, foundVlan)
}

Expand Down Expand Up @@ -232,7 +233,7 @@ func TestAccMetalVlan_importBasic(t *testing.T) {
}

func TestAccMetalVlan_facility_to_metro(t *testing.T) {
var vlan packngo.VirtualNetwork
var vlan metalv1.VirtualNetwork
rs := acctest.RandString(10)
metro := "sv"
facility := "sv15"
Expand Down Expand Up @@ -273,7 +274,7 @@ func TestAccMetalVlan_facility_to_metro(t *testing.T) {
}

func TestAccMetalVlan_metro_upgradeFromVersion(t *testing.T) {
var vlan packngo.VirtualNetwork
var vlan metalv1.VirtualNetwork
rs := acctest.RandString(10)
metro := "sv"

Expand Down Expand Up @@ -311,7 +312,7 @@ func TestAccMetalVlan_metro_upgradeFromVersion(t *testing.T) {
}

func TestAccMetalVlan_metro_suppress_diff(t *testing.T) {
var vlan packngo.VirtualNetwork
var vlan metalv1.VirtualNetwork
rs := acctest.RandString(10)
metro := "sv"

Expand Down

0 comments on commit 5b5800d

Please sign in to comment.