Skip to content

Commit

Permalink
Fix linter errors that propagated to the rest of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
thogarty committed Feb 15, 2025
1 parent 09ef27e commit 335ac9a
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 135 deletions.
18 changes: 9 additions & 9 deletions equinix/data_source_fabric_port_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"testing"

"github.com/equinix/terraform-provider-equinix/internal/acceptance"
"github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
testinghelpers "github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"

"github.com/equinix/equinix-sdk-go/services/fabricv4"

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

func TestAccDataSourceFabricPort_PNFV(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
ports := testinghelpers.GetFabricEnvPorts(t)
var port fabricv4.Port
var portType, portState, portEncapsulationType, portRedundancyPriority string
if len(ports) > 0 {
Expand Down Expand Up @@ -57,16 +57,16 @@ func TestAccDataSourceFabricPort_PNFV(t *testing.T) {
})
}

func testDataSourceFabricPort(port_uuid string) string {
func testDataSourceFabricPort(portUUID string) string {
return fmt.Sprintf(`
data "equinix_fabric_port" "test" {
uuid = "%s"
}`,
port_uuid)
portUUID)
}

func TestAccDataSourceFabricPorts_PNFV(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
ports := testinghelpers.GetFabricEnvPorts(t)
var port fabricv4.Port
var portType, portState, portEncapsulationType, portRedundancyPriority string
if len(ports) > 0 {
Expand Down Expand Up @@ -110,18 +110,18 @@ func TestAccDataSourceFabricPorts_PNFV(t *testing.T) {
})
}

func testDataSourceFabricPorts(port_name string) string {
func testDataSourceFabricPorts(portName string) string {
return fmt.Sprintf(`
data "equinix_fabric_ports" "test" {
filters {
name = "%s"
}
}`,
port_name)
portName)
}

func TestAccDataSourceFabricPort_PPDS(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
ports := testinghelpers.GetFabricEnvPorts(t)
var port fabricv4.Port
var portType, portState, portEncapsulationType, portRedundancyPriority string
if len(ports) > 0 {
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestAccDataSourceFabricPort_PPDS(t *testing.T) {
}

func TestAccDataSourceFabricPorts_PPDS(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
ports := testinghelpers.GetFabricEnvPorts(t)
var port fabricv4.Port
var portType, portState, portEncapsulationType, portRedundancyPriority string
if len(ports) > 0 {
Expand Down
13 changes: 7 additions & 6 deletions equinix/data_source_fabric_service_profile_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package equinix_test

import (
"fmt"
"testing"

"github.com/equinix/terraform-provider-equinix/internal/acceptance"
"github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
testinghelpers "github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"testing"
)

func testAccFabricReadServiceProfileConfig(spName string, portUUID string, portType string, portMetroCode string) string {
Expand Down Expand Up @@ -76,12 +77,12 @@ data "equinix_fabric_service_profiles" "test" {
}

func TestAccFabricServiceProfileDataSources_PFCR(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
ports := testinghelpers.GetFabricEnvPorts(t)

var portUuid, portMetroCode, portType string
var portUUID, portMetroCode, portType string
if len(ports) > 0 {
port := ports["pfcr"]["dot1q"][0]
portUuid = port.GetUuid()
portUUID = port.GetUuid()
portMetroCodeLocation := port.GetLocation()
portMetroCode = portMetroCodeLocation.GetMetroCode()
portType = string(port.GetType())
Expand All @@ -93,7 +94,7 @@ func TestAccFabricServiceProfileDataSources_PFCR(t *testing.T) {
CheckDestroy: checkServiceProfileDelete,
Steps: []resource.TestStep{
{
Config: testAccFabricReadServiceProfileConfig("SP_DataSource_PFCR", portUuid, portType, portMetroCode),
Config: testAccFabricReadServiceProfileConfig("SP_DataSource_PFCR", portUUID, portType, portMetroCode),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.equinix_fabric_service_profile.test", "name", "SP_DataSource_PFCR"),
Expand Down
14 changes: 7 additions & 7 deletions equinix/resource_fabric_routing_protocol_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/equinix/terraform-provider-equinix/equinix"
"github.com/equinix/terraform-provider-equinix/internal/acceptance"
"github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
testinghelpers "github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand All @@ -22,12 +22,12 @@ import (
// data_source tests will just leverage the RPs there to retrieve the data and check results

func TestAccFabricCreateRoutingProtocols_PFCR(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
ports := testinghelpers.GetFabricEnvPorts(t)

var portUuid string
var portUUID string

if len(ports) > 0 {
portUuid = ports["pfcr"]["dot1q"][1].GetUuid()
portUUID = ports["pfcr"]["dot1q"][1].GetUuid()
}

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -36,7 +36,7 @@ func TestAccFabricCreateRoutingProtocols_PFCR(t *testing.T) {
CheckDestroy: checkRoutingProtocolDelete,
Steps: []resource.TestStep{
{
Config: testAccFabricCreateRoutingProtocolConfig("RP_Conn_Test_PFCR", portUuid),
Config: testAccFabricCreateRoutingProtocolConfig("RP_Conn_Test_PFCR", portUUID),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("equinix_fabric_routing_protocol.direct", "id"),
resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.direct", "type", "DIRECT"),
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestAccFabricCreateRoutingProtocols_PFCR(t *testing.T) {
})
}

func testAccFabricCreateRoutingProtocolConfig(name, portUuid string) string {
func testAccFabricCreateRoutingProtocolConfig(name, portUUID string) string {
return fmt.Sprintf(`
resource "equinix_fabric_cloud_router" "this" {
Expand Down Expand Up @@ -204,7 +204,7 @@ data "equinix_fabric_routing_protocol" "bgp" {
uuid = equinix_fabric_routing_protocol.bgp.id
}
`, name, portUuid)
`, name, portUUID)
}

func checkRoutingProtocolDelete(s *terraform.State) error {
Expand Down
21 changes: 11 additions & 10 deletions equinix/resource_fabric_service_profile_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@ package equinix_test
import (
"context"
"fmt"
"testing"
"time"

"github.com/equinix/terraform-provider-equinix/equinix"
"github.com/equinix/terraform-provider-equinix/internal/acceptance"
"github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
testinghelpers "github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"testing"
"time"

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

func TestAccFabricCreateServiceProfile_PFCR(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
ports := testinghelpers.GetFabricEnvPorts(t)

var portUuidDot1Q, portMetroCodeDot1Q, portTypeDot1Q string
var portUuidQinq, portMetroCodeQinq, portTypeQinq string
var portUUIDDot1Q, portMetroCodeDot1Q, portTypeDot1Q string
var portUUIDQinq, portMetroCodeQinq, portTypeQinq string
if len(ports) > 0 {
portDot1Q := ports["pfcr"]["dot1q"][0]
portQinq := ports["pfcr"]["qinq"][0]
portUuidDot1Q = portDot1Q.GetUuid()
portUUIDDot1Q = portDot1Q.GetUuid()
portMetroCodeDot1QLocation := portDot1Q.GetLocation()
portMetroCodeDot1Q = portMetroCodeDot1QLocation.GetMetroCode()
portTypeDot1Q = string(portDot1Q.GetType())
portUuidQinq = portQinq.GetUuid()
portUUIDQinq = portQinq.GetUuid()
portMetroCodeQinqLocation := portQinq.GetLocation()
portMetroCodeQinq = portMetroCodeQinqLocation.GetMetroCode()
portTypeQinq = string(portQinq.GetType())
Expand All @@ -38,7 +39,7 @@ func TestAccFabricCreateServiceProfile_PFCR(t *testing.T) {
CheckDestroy: checkServiceProfileDelete,
Steps: []resource.TestStep{
{
Config: testAccFabricCreateServiceProfileConfig(portUuidDot1Q, portTypeDot1Q, portMetroCodeDot1Q),
Config: testAccFabricCreateServiceProfileConfig(portUUIDDot1Q, portTypeDot1Q, portMetroCodeDot1Q),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"equinix_fabric_service_profile.test", "name", "SP_ResourceCreation_PFCR"),
Expand Down Expand Up @@ -70,7 +71,7 @@ func TestAccFabricCreateServiceProfile_PFCR(t *testing.T) {
ExpectNonEmptyPlan: true,
},
{
Config: testAccFabricCreateServiceProfileConfig(portUuidQinq, portTypeQinq, portMetroCodeQinq),
Config: testAccFabricCreateServiceProfileConfig(portUUIDQinq, portTypeQinq, portMetroCodeQinq),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"equinix_fabric_service_profile.test", "name", "SP_ResourceCreation_PFCR"),
Expand Down
26 changes: 13 additions & 13 deletions internal/fabric/testing_helpers/env_data.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing_helpers
package testinghelpers

import (
"encoding/json"
Expand All @@ -19,32 +19,32 @@ type EnvPorts map[string]map[string][]fabricv4.Port

func GetFabricEnvPorts(t *testing.T) EnvPorts {
var ports EnvPorts
portJson := os.Getenv(FabricDedicatedPortEnvVar)
if err := json.Unmarshal([]byte(portJson), &ports); portJson != "" && err != nil {
t.Fatalf("Failed reading port data from environment: %v, %s", err, portJson)
portJSON := os.Getenv(FabricDedicatedPortEnvVar)
if err := json.Unmarshal([]byte(portJSON), &ports); portJSON != "" && err != nil {
t.Fatalf("Failed reading port data from environment: %v, %s", err, portJSON)
}
return ports
}

func GetFabricEnvConnectionTestData(t *testing.T) map[string]map[string]string {
var connectionTestData map[string]map[string]string
connectionTestDataJson := os.Getenv(FabricConnectionsTestDataEnvVar)
if err := json.Unmarshal([]byte(connectionTestDataJson), &connectionTestData); connectionTestDataJson != "" && err != nil {
t.Fatalf("Failed reading connection data from environment: %v, %s", err, connectionTestDataJson)
connectionTestDataJSON := os.Getenv(FabricConnectionsTestDataEnvVar)
if err := json.Unmarshal([]byte(connectionTestDataJSON), &connectionTestData); connectionTestDataJSON != "" && err != nil {
t.Fatalf("Failed reading connection data from environment: %v, %s", err, connectionTestDataJSON)
}
return connectionTestData
}

func GetFabricMarketPlaceSubscriptionId(t *testing.T) string {
subscriptionId := os.Getenv(FabricSubscriptionEnvVar)
return subscriptionId
func GetFabricMarketPlaceSubscriptionID(_ *testing.T) string {
subscriptionID := os.Getenv(FabricSubscriptionEnvVar)
return subscriptionID
}

func GetFabricStreamTestData(t *testing.T) map[string]map[string]string {
var streamTestData map[string]map[string]string
streamJson := os.Getenv(FabricStreamEnvVar)
if err := json.Unmarshal([]byte(streamJson), &streamTestData); streamJson != "" && err != nil {
t.Fatalf("failed reading stream data from environment: %v, %s", err, streamJson)
streamJSON := os.Getenv(FabricStreamEnvVar)
if err := json.Unmarshal([]byte(streamJSON), &streamTestData); streamJSON != "" && err != nil {
t.Fatalf("failed reading stream data from environment: %v, %s", err, streamJSON)
}
return streamTestData
}
5 changes: 3 additions & 2 deletions internal/resources/fabric/connection/datasources_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package connection

import (
"fmt"
"regexp"

"github.com/equinix/equinix-sdk-go/services/fabricv4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"regexp"
)

func readFabricConnectionResourceSchema() map[string]*schema.Schema {
sch := fabricConnectionResourceSchema()
for key, _ := range sch {
for key := range sch {
if key == "uuid" {
sch[key].Required = true
sch[key].Optional = false
Expand Down
19 changes: 10 additions & 9 deletions internal/resources/fabric/connection/datasources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ package connection_test

import (
"fmt"
"testing"

"github.com/equinix/terraform-provider-equinix/internal/acceptance"
"github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
testinghelpers "github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"testing"
)

func TestAccFabricDataSourceConnection_PFCR(t *testing.T) {
ports := testing_helpers.GetFabricEnvPorts(t)
var aSidePortUuid, zSidePortUuid string
ports := testinghelpers.GetFabricEnvPorts(t)
var aSidePortUUID, zSidePortUUID string
if len(ports) > 0 {
aSidePortUuid = ports["pfcr"]["dot1q"][0].GetUuid()
zSidePortUuid = ports["pfcr"]["dot1q"][1].GetUuid()
aSidePortUUID = ports["pfcr"]["dot1q"][0].GetUuid()
zSidePortUUID = ports["pfcr"]["dot1q"][1].GetUuid()
}
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheck(t); acceptance.TestAccPreCheckProviderConfigured(t) },
Providers: acceptance.TestAccProviders,
CheckDestroy: CheckConnectionDelete,
Steps: []resource.TestStep{
{
Config: testAccFabricDataSourceConnectionConfig(50, aSidePortUuid, zSidePortUuid),
Config: testAccFabricDataSourceConnectionConfig(50, aSidePortUUID, zSidePortUUID),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.equinix_fabric_connection.test", "id"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -84,7 +85,7 @@ func TestAccFabricDataSourceConnection_PFCR(t *testing.T) {
})
}

func testAccFabricDataSourceConnectionConfig(bandwidth int32, aSidePortUuid, zSidePortUuid string) string {
func testAccFabricDataSourceConnectionConfig(bandwidth int32, aSidePortUUID, zSidePortUUID string) string {
return fmt.Sprintf(`
resource "equinix_fabric_connection" "test" {
Expand Down Expand Up @@ -142,5 +143,5 @@ data "equinix_fabric_connections" "connections" {
}
}
`, bandwidth, aSidePortUuid, zSidePortUuid)
`, bandwidth, aSidePortUUID, zSidePortUUID)
}
Loading

0 comments on commit 335ac9a

Please sign in to comment.