Skip to content

Commit

Permalink
test: add tests for available_prefix resource custom fields support
Browse files Browse the repository at this point in the history
Signed-off-by: Xabier Napal <[email protected]>
  • Loading branch information
xabinapal committed Dec 24, 2024
1 parent 3f9355a commit 6618afb
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions netbox/resource_netbox_available_prefix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,50 @@ resource "netbox_available_prefix" "test" {
})
}

func TestAccNetboxAvailablePrefix_cf(t *testing.T) {
testParentPrefix := "1.1.0.0/24"
testPrefixLength := 25
expectedPrefix := "1.1.0.0/25"
testSlug := "prefix_cf"
testDesc := "test cf prefix"
testName := testAccGetTestName(testSlug)

resourceName := "netbox_available_prefix.test"

resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccNetboxAvailablePrefixFullDependencies(testName, testParentPrefix) + fmt.Sprintf(`
resource "netbox_custom_field" "test" {
name = "%s"
type = "text"
weight = 100
content_types = ["ipam.prefix"]
}
resource "netbox_available_prefix" "test" {
parent_prefix_id = netbox_prefix.parent.id
prefix_length = %d
description = "%s"
status = "active"
tags = [netbox_tag.test.name]
mark_utilized = true
is_pool = true
custom_fields = {
"${netbox_custom_field.test.name}" = "test-field"
}
}`, testSlug, testPrefixLength, testDesc),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "prefix", expectedPrefix),
//resource.TestCheckResourceAttr("netbox_available_prefix.test", fmt.Sprintf("custom_fields.%s", testSlug), "test-field"),
),
},
},
})
}

func TestAccNetboxAvailablePrefix_multiplePrefixesSerial(t *testing.T) {
testParentPrefix := "1.1.0.0/24"
testPrefixLength := 25
Expand Down

0 comments on commit 6618afb

Please sign in to comment.