Skip to content

Commit

Permalink
add test to validate removing the VLAN description
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Apr 5, 2024
1 parent d033309 commit d2f31db
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/resources/metal/vlan/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,42 @@ func TestAccMetalVlan_NoDescription(t *testing.T) {
},
})
}

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

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheckMetal(t) },
ExternalProviders: acceptance.TestExternalProviders,
ProtoV5ProviderFactories: acceptance.ProtoV5ProviderFactories,
CheckDestroy: testAccMetalVlanCheckDestroyed,
Steps: []resource.TestStep{
{
Config: testAccCheckMetalVlanConfig_metro(rs, metro, "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),
),
},
{
Config: testAccCheckMetalVlanConfig_NoDescription(rs, metro),
Check: resource.ComposeTestCheckFunc(
testAccCheckMetalVlanExists("equinix_metal_vlan.foovlan", &vlan),
resource.TestCheckNoResourceAttr(
"equinix_metal_vlan.foovlan", "description"),
resource.TestCheckResourceAttr(
"equinix_metal_vlan.foovlan", "metro", metro),
),
},
},
})
}

func testAccCheckMetalVlanExists(n string, vlan *packngo.VirtualNetwork) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down

0 comments on commit d2f31db

Please sign in to comment.