From b47e36cfaa89fcc1a224a15b9e9a4fff12ceb1a9 Mon Sep 17 00:00:00 2001
From: Fabian Breckle <fabian.breckle@breuninger.de>
Date: Fri, 4 Aug 2023 09:42:29 +0200
Subject: [PATCH] test: Add test that unsets interface.enabled

---
 netbox/resource_netbox_interface_test.go | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/netbox/resource_netbox_interface_test.go b/netbox/resource_netbox_interface_test.go
index 6dadd7da..b575356e 100644
--- a/netbox/resource_netbox_interface_test.go
+++ b/netbox/resource_netbox_interface_test.go
@@ -56,16 +56,16 @@ resource "netbox_interface" "test" {
 }`, testName)
 }
 
-func testAccNetboxInterfaceOpts(testName string, testMac string) string {
+func testAccNetboxInterfaceOpts(testName string, testMac string, enabled string) string {
 	return fmt.Sprintf(`
 resource "netbox_interface" "test" {
   name = "%[1]s"
   description = "%[1]s"
-  enabled = true
+  enabled = %[3]s
   mac_address = "%[2]s"
   mtu = 1440
   virtual_machine_id = netbox_virtual_machine.test.id
-}`, testName, testMac)
+}`, testName, testMac, enabled)
 }
 
 func testAccNetboxInterfaceVlans(testName string) string {
@@ -131,7 +131,7 @@ func TestAccNetboxInterface_opts(t *testing.T) {
 		CheckDestroy: testAccCheckInterfaceDestroy,
 		Steps: []resource.TestStep{
 			{
-				Config: setUp + testAccNetboxInterfaceOpts(testName, testMac),
+				Config: setUp + testAccNetboxInterfaceOpts(testName, testMac, "true"),
 				Check: resource.ComposeTestCheckFunc(
 					resource.TestCheckResourceAttr("netbox_interface.test", "name", testName),
 					resource.TestCheckResourceAttr("netbox_interface.test", "description", testName),
@@ -141,6 +141,17 @@ func TestAccNetboxInterface_opts(t *testing.T) {
 					resource.TestCheckResourceAttrPair("netbox_interface.test", "virtual_machine_id", "netbox_virtual_machine.test", "id"),
 				),
 			},
+			{
+				Config: setUp + testAccNetboxInterfaceOpts(testName, testMac, "false"),
+				Check: resource.ComposeTestCheckFunc(
+					resource.TestCheckResourceAttr("netbox_interface.test", "name", testName),
+					resource.TestCheckResourceAttr("netbox_interface.test", "description", testName),
+					resource.TestCheckResourceAttr("netbox_interface.test", "enabled", "false"),
+					resource.TestCheckResourceAttr("netbox_interface.test", "mac_address", "00:01:02:03:04:05"),
+					resource.TestCheckResourceAttr("netbox_interface.test", "mtu", "1440"),
+					resource.TestCheckResourceAttrPair("netbox_interface.test", "virtual_machine_id", "netbox_virtual_machine.test", "id"),
+				),
+			},
 			{
 				ResourceName:      "netbox_interface.test",
 				ImportState:       true,