From db9e3c036b23b4cee40d0ea411986fd3397db19f Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Fri, 5 Apr 2024 11:53:34 -0500 Subject: [PATCH] add test to validate removing the VLAN description --- .../resources/metal/vlan/resource_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/internal/resources/metal/vlan/resource_test.go b/internal/resources/metal/vlan/resource_test.go index 52cfad0b2..a4a297a3e 100644 --- a/internal/resources/metal/vlan/resource_test.go +++ b/internal/resources/metal/vlan/resource_test.go @@ -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]