Skip to content

Commit

Permalink
fix a bug where rrdatas can not be unset in google_dns_record_set (
Browse files Browse the repository at this point in the history
  • Loading branch information
shuyama1 authored Jun 13, 2022
1 parent 5bd7e2c commit de682a2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
)

func rrdatasDnsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
if k == "rrdatas.#" && new == "0" && old != new {
return false
}

o, n := d.GetChange("rrdatas")
if o == nil || n == nil {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,37 @@ func TestAccDNSRecordSet_routingPolicy(t *testing.T) {
})
}

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

zoneName := fmt.Sprintf("dnszone-test-%s", randString(t, 10))
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDnsRecordSetDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDnsRecordSet_basic(zoneName, "127.0.0.10", 300),
},
{
ResourceName: "google_dns_record_set.foobar",
ImportStateId: fmt.Sprintf("%s/%s/test-record.%s.hashicorptest.com./A", getTestProjectFromEnv(), zoneName, zoneName),
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDnsRecordSet_routingPolicyGEO(zoneName, "127.0.0.10", 300, "us-central1"),
},
{
ResourceName: "google_dns_record_set.foobar",
ImportStateId: fmt.Sprintf("%s/%s/test-record.%s.hashicorptest.com./A", getTestProjectFromEnv(), zoneName, zoneName),
ImportState: true,
ImportStateVerify: true,
},
},
})
}


func testAccCheckDnsRecordSetDestroyProducer(t *testing.T) func(s *terraform.State) error {

Expand Down

0 comments on commit de682a2

Please sign in to comment.