@@ -90,10 +90,6 @@ func TestAccRecord_updated(t *testing.T) {
9090 testAccCheckRecordAnswerRdata (
9191 t , & record , 0 , []string {fmt .Sprintf ("test2.%s" , zoneName )},
9292 ),
93- testAccCheckRecordTagData (
94- map [string ]string {"tag1" : "location1" , "tag2" : "location2" },
95- & record ,
96- ),
9793 ),
9894 },
9995 {
@@ -453,6 +449,59 @@ func TestAccRecord_WithTags(t *testing.T) {
453449 })
454450}
455451
452+ func TestAccRecord_updatedWithTags (t * testing.T ) {
453+ var record dns.Record
454+ rString := acctest .RandStringFromCharSet (15 , acctest .CharSetAlphaNum )
455+ zoneName := fmt .Sprintf ("terraform-test-%s.io" , rString )
456+ domainName := fmt .Sprintf ("test.%s" , zoneName )
457+
458+ resource .Test (t , resource.TestCase {
459+ PreCheck : func () { testAccPreCheck (t ) },
460+ Providers : testAccProviders ,
461+ CheckDestroy : testAccCheckRecordDestroy ,
462+ Steps : []resource.TestStep {
463+ {
464+ Config : testAccRecordBasic (rString ),
465+ Check : resource .ComposeTestCheckFunc (
466+ testAccCheckRecordExists ("ns1_record.it" , & record ),
467+ testAccCheckRecordDomain (& record , domainName ),
468+ testAccCheckRecordTTL (& record , 60 ),
469+ testAccCheckRecordUseClientSubnet (& record , true ),
470+ testAccCheckRecordRegionName (& record , []string {"cal" }),
471+ // testAccCheckRecordAnswerMetaWeight(&record, 10),
472+ testAccCheckRecordAnswerRdata (
473+ t , & record , 0 , []string {fmt .Sprintf ("test1.%s" , zoneName )},
474+ ),
475+ ),
476+ },
477+ {
478+ Config : testAccRecordUpdatedWithTags (rString ),
479+ Check : resource .ComposeTestCheckFunc (
480+ testAccCheckRecordExists ("ns1_record.it" , & record ),
481+ testAccCheckRecordDomain (& record , domainName ),
482+ testAccCheckRecordTTL (& record , 120 ),
483+ testAccCheckRecordUseClientSubnet (& record , false ),
484+ testAccCheckRecordRegionName (& record , []string {"ny" , "wa" }),
485+ // testAccCheckRecordAnswerMetaWeight(&record, 5),
486+ testAccCheckRecordAnswerRdata (
487+ t , & record , 0 , []string {fmt .Sprintf ("test2.%s" , zoneName )},
488+ ),
489+ testAccCheckRecordTagData (
490+ map [string ]string {"tag1" : "location1" , "tag2" : "location2" },
491+ & record ,
492+ ),
493+ ),
494+ },
495+ {
496+ ResourceName : "ns1_record.it" ,
497+ ImportState : true ,
498+ ImportStateId : fmt .Sprintf ("%s/%s/CNAME" , zoneName , domainName ),
499+ ImportStateVerify : true ,
500+ },
501+ },
502+ })
503+ }
504+
456505func TestAccRecord_validationError (t * testing.T ) {
457506 rString := acctest .RandStringFromCharSet (15 , acctest .CharSetAlphaNum )
458507
@@ -1247,8 +1296,6 @@ resource "ns1_record" "it" {
12471296 filters {
12481297 filter = "geotarget_country"
12491298 }
1250-
1251- tags = {tag1: "location1", tag2: "location2"}
12521299}
12531300
12541301resource "ns1_zone" "test" {
@@ -1533,6 +1580,63 @@ resource "ns1_zone" "test" {
15331580` , rString )
15341581}
15351582
1583+ func testAccRecordUpdatedWithTags (rString string ) string {
1584+ return fmt .Sprintf (`
1585+ resource "ns1_record" "it" {
1586+ zone = "${ns1_zone.test.zone}"
1587+ domain = "test.${ns1_zone.test.zone}"
1588+ type = "CNAME"
1589+ ttl = 120
1590+ use_client_subnet = false
1591+
1592+ // meta {
1593+ // weight = 5
1594+ // connections = 3
1595+ // // up = false // Ignored by d.GetOk("meta.0.up") due to known issue
1596+ // }
1597+
1598+ answers {
1599+ answer = "test2.${ns1_zone.test.zone}"
1600+ region = "ny"
1601+
1602+ // meta {
1603+ // weight = 5
1604+ // up = true
1605+ // }
1606+ }
1607+
1608+ regions {
1609+ name = "ny"
1610+ // meta {
1611+ // us_state = ["NY"]
1612+ // }
1613+ }
1614+
1615+ regions {
1616+ name = "wa"
1617+ // meta {
1618+ // us_state = ["WA"]
1619+ // }
1620+ }
1621+
1622+ filters {
1623+ filter = "select_first_n"
1624+ config = {N=1}
1625+ }
1626+
1627+ filters {
1628+ filter = "geotarget_country"
1629+ }
1630+
1631+ tags = {tag1: "location1", tag2: "location2"}
1632+ }
1633+
1634+ resource "ns1_zone" "test" {
1635+ zone = "terraform-test-%s.io"
1636+ }
1637+ ` , rString )
1638+ }
1639+
15361640// zone and domain have leading and trailing dots and should fail validation.
15371641func testAccRecordInvalid (rString string ) string {
15381642 return fmt .Sprintf (`
0 commit comments