Skip to content

Commit

Permalink
Update provider factories for all tests using vlans
Browse files Browse the repository at this point in the history
Signed-off-by: Ayush Rangwala <[email protected]>
  • Loading branch information
aayushrangwala committed Feb 22, 2024
1 parent 97ed959 commit 146690f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 42 deletions.
40 changes: 20 additions & 20 deletions equinix/resource_metal_port_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ resource "equinix_metal_vlan" "test" {
func TestAccMetalPort_hybridBondedVxlan(t *testing.T) {
rs := acctest.RandString(10)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
Steps: []resource.TestStep{
{
Config: confAccMetalPort_HybridBondedVxlan(rs),
Expand All @@ -266,10 +266,10 @@ func TestAccMetalPort_hybridBondedVxlan(t *testing.T) {
func TestAccMetalPort_L2IndividualNativeVlan(t *testing.T) {
rs := acctest.RandString(10)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
Steps: []resource.TestStep{
{
Config: confAccMetalPort_L2IndividualNativeVlan(rs),
Expand Down Expand Up @@ -299,10 +299,10 @@ func TestAccMetalPort_L2IndividualNativeVlan(t *testing.T) {
func testAccMetalPortTemplate(t *testing.T, conf func(string) string, expectedType string) {
rs := acctest.RandString(10)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
Steps: []resource.TestStep{
{
Config: conf(rs),
Expand Down Expand Up @@ -422,10 +422,10 @@ func TestAccMetalPortCreate_hybridBonded_timeout(t *testing.T) {
deviceName := "equinix_metal_device.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
Steps: []resource.TestStep{
{
Config: confAccMetalPort_HybridBonded_timeout(rInt, rs, "5s", ""),
Expand Down Expand Up @@ -463,10 +463,10 @@ func TestAccMetalPortUpdate_hybridBonded_timeout(t *testing.T) {
rInt := acctest.RandInt()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortDestroyed,
Steps: []resource.TestStep{
{
Config: confAccMetalPort_HybridBonded_timeout(rInt, rs, "", "5s"),
Expand Down
40 changes: 20 additions & 20 deletions equinix/resource_metal_port_vlan_attachment_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func TestAccMetalPortVlanAttachment_L2Bonded(t *testing.T) {
rs := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
Providers: testAccProviders,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
Steps: []resource.TestStep{
{
Config: testAccMetalPortVlanAttachmentConfig_L2Bonded_1(rs),
Expand Down Expand Up @@ -161,10 +161,10 @@ func TestAccMetalPortVlanAttachment_L2Individual(t *testing.T) {
rs := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
Providers: testAccProviders,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
Steps: []resource.TestStep{
{
Config: testAccMetalPortVlanAttachmentConfig_L2Individual_1(rs),
Expand Down Expand Up @@ -237,10 +237,10 @@ func TestAccMetalPortVlanAttachment_hybridBasic(t *testing.T) {
rs := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
Providers: testAccProviders,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
Steps: []resource.TestStep{
{
Config: testAccMetalPortVlanAttachmentConfig_Hybrid_1(rs),
Expand Down Expand Up @@ -312,10 +312,10 @@ func TestAccMetalPortVlanAttachment_hybridMultipleVlans(t *testing.T) {
rs := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
Providers: testAccProviders,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
Steps: []resource.TestStep{
{
Config: testAccMetalPortVlanAttachmentConfig_HybridMultipleVlans_1(rs),
Expand Down Expand Up @@ -443,10 +443,10 @@ func TestAccMetalPortVlanAttachment_L2Native(t *testing.T) {
rs := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
Providers: testAccProviders,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
CheckDestroy: testAccMetalPortVlanAttachmentCheckDestroyed,
Steps: []resource.TestStep{
{
Config: testAccMetalPortVlanAttachmentConfig_L2Native_1(rs),
Expand Down
11 changes: 9 additions & 2 deletions internal/resources/metal/vlans/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ type DataSourceModel struct {

func (m *DataSourceModel) parse(vlan *packngo.VirtualNetwork) diag.Diagnostics {
m.ID = types.StringValue(vlan.ID)
m.ProjectID = types.StringValue(vlan.Project.ID)

if vlan.Project.ID != "" {
m.ProjectID = types.StringValue(vlan.Project.ID)
}

m.VlanID = types.StringValue(vlan.ID)

m.Facility = types.StringNull()
Expand Down Expand Up @@ -50,7 +54,10 @@ type ResourceModel struct {

func (m *ResourceModel) parse(vlan *packngo.VirtualNetwork) diag.Diagnostics {
m.ID = types.StringValue(vlan.ID)
m.ProjectID = types.StringValue(vlan.Project.ID)

if vlan.Project.ID != "" {
m.ProjectID = types.StringValue(vlan.Project.ID)
}

m.Facility = types.StringNull()
if vlan.FacilityCode != "" {
Expand Down

0 comments on commit 146690f

Please sign in to comment.