Skip to content

Commit

Permalink
test: Add test that unsets interface.enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fbreckle committed Aug 4, 2023
1 parent a41f4ea commit b47e36c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions netbox/resource_netbox_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand All @@ -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,
Expand Down

0 comments on commit b47e36c

Please sign in to comment.