Skip to content

Commit

Permalink
regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexluong committed Sep 3, 2024
1 parent 20b8cf8 commit b6bdeb5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions internal/sdkv2provider/resource_cloudflare_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cloudflare/terraform-provider-cloudflare/internal/consts"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -672,6 +673,35 @@ func TestAccCloudflareRecord_ClearTags(t *testing.T) {
})
}

func TestAccCloudflareRecord_CompareIPv6(t *testing.T) {
t.Parallel()
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID")
rnd := generateRandomResourceName()
name := fmt.Sprintf("cloudflare_record.%s", rnd)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckCloudflareRecordDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckCloudflareRecordConfigIPv6(zoneID, rnd, rnd, "2001:4860:4860:0:0:0:0:8888"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, "name", rnd),
resource.TestCheckResourceAttr(name, "type", "AAAA"),
resource.TestCheckResourceAttr(name, "content", "2001:4860:4860:0:0:0:0:8888"),
),
},
{
Config: testAccCheckCloudflareRecordConfigIPv6(zoneID, rnd, rnd, "2001:4860:4860::8888"),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{plancheck.ExpectEmptyPlan()},
},
},
},
})
}

func TestSuppressTrailingDots(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1076,3 +1106,14 @@ func testAccCheckCloudflareRecordDNSKEY(zoneID, name string) string {
}
`, zoneID, name)
}

func testAccCheckCloudflareRecordConfigIPv6(zoneID, name, rnd, content string) string {
return fmt.Sprintf(`
resource "cloudflare_record" "%[3]s" {
zone_id = "%[1]s"
name = "%[2]s"
content = "%[4]s"
type = "AAAA"
ttl = 3600
}`, zoneID, name, rnd, content)
}

0 comments on commit b6bdeb5

Please sign in to comment.