Skip to content

Commit

Permalink
rename test variables & annotate with comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Apr 8, 2024
1 parent bc903ac commit 7ffb3a3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions internal/resources/metal/vlan/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ resource "equinix_metal_vlan" "foovlan" {
func TestAccMetalVlan_metro(t *testing.T) {
var vlan packngo.VirtualNetwork
rs := acctest.RandString(10)
metro := "sv"
upperMetro := "DA"
lowerSiliconValley := "sv"
upperDallas := "DA"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheckMetal(t) },
Expand All @@ -68,21 +68,24 @@ func TestAccMetalVlan_metro(t *testing.T) {
CheckDestroy: testAccMetalVlanCheckDestroyed,
Steps: []resource.TestStep{
{
Config: testAccCheckMetalVlanConfig_metro(rs, metro, "tfacc-vlan"),
// Create VLAN with metro "sv" (lower-case)
Config: testAccCheckMetalVlanConfig_metro(rs, lowerSiliconValley, "tfacc-vlan"),
Check: resource.ComposeTestCheckFunc(
testAccCheckMetalVlanExists("equinix_metal_vlan.foovlan", &vlan),
resource.TestCheckResourceAttr(
"equinix_metal_vlan.foovlan", "description", "tfacc-vlan"),
resource.TestCheckResourceAttr(
"equinix_metal_vlan.foovlan", "metro", metro),
"equinix_metal_vlan.foovlan", "metro", lowerSiliconValley),
),
},
{
Config: testAccCheckMetalVlanConfig_metro(rs, strings.ToUpper(metro), "tfacc-vlan"),
// Confirm no changes if metro is changed to "SV" (upper-case)
Config: testAccCheckMetalVlanConfig_metro(rs, strings.ToUpper(lowerSiliconValley), "tfacc-vlan"),
PlanOnly: true,
},
{
Config: testAccCheckMetalVlanConfig_metro(rs, upperMetro, "tfacc-vlan"),
// Recreate VLAN with metro "DA" (upper-case)
Config: testAccCheckMetalVlanConfig_metro(rs, upperDallas, "tfacc-vlan"),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("equinix_metal_vlan.foovlan", plancheck.ResourceActionDestroyBeforeCreate),
Expand All @@ -93,11 +96,12 @@ func TestAccMetalVlan_metro(t *testing.T) {
resource.TestCheckResourceAttr(
"equinix_metal_vlan.foovlan", "description", "tfacc-vlan"),
resource.TestCheckResourceAttr(
"equinix_metal_vlan.foovlan", "metro", upperMetro),
"equinix_metal_vlan.foovlan", "metro", upperDallas),
),
},
{
Config: testAccCheckMetalVlanConfig_metro(rs, strings.ToLower(upperMetro), "tfacc-vlan"),
// Confirm no changes if metro is changed to "da" (lower-case)
Config: testAccCheckMetalVlanConfig_metro(rs, strings.ToLower(upperDallas), "tfacc-vlan"),
PlanOnly: true,
},
},
Expand Down

0 comments on commit 7ffb3a3

Please sign in to comment.