@@ -102,6 +102,41 @@ func TestAccRecord_updated(t *testing.T) {
102102 })
103103}
104104
105+ func TestAccRecord_remove_all_filters (t * testing.T ) {
106+ var record dns.Record
107+ rString := acctest .RandStringFromCharSet (15 , acctest .CharSetAlphaNum )
108+ zoneName := fmt .Sprintf ("terraform-test-%s.io" , rString )
109+ domainName := fmt .Sprintf ("test.%s" , zoneName )
110+
111+ resource .Test (t , resource.TestCase {
112+ PreCheck : func () { testAccPreCheck (t ) },
113+ Providers : testAccProviders ,
114+ CheckDestroy : testAccCheckRecordDestroy ,
115+ Steps : []resource.TestStep {
116+ {
117+ Config : testAccRecordBasic (rString ),
118+ Check : resource .ComposeTestCheckFunc (
119+ testAccCheckRecordExists ("ns1_record.it" , & record ),
120+ testAccCheckRecordFilterCount (& record , 3 ),
121+ ),
122+ },
123+ {
124+ Config : testAccRecordUpdatedNoFilters (rString ),
125+ Check : resource .ComposeTestCheckFunc (
126+ testAccCheckRecordExists ("ns1_record.it" , & record ),
127+ testAccCheckRecordFilterCount (& record , 0 ),
128+ ),
129+ },
130+ {
131+ ResourceName : "ns1_record.it" ,
132+ ImportState : true ,
133+ ImportStateId : fmt .Sprintf ("%s/%s/CNAME" , zoneName , domainName ),
134+ ImportStateVerify : true ,
135+ },
136+ },
137+ })
138+ }
139+
105140func TestAccRecord_meta (t * testing.T ) {
106141 var record dns.Record
107142 rString := acctest .RandStringFromCharSet (15 , acctest .CharSetAlphaNum )
@@ -784,6 +819,16 @@ func testAccCheckRecordExists(n string, record *dns.Record) resource.TestCheckFu
784819 }
785820}
786821
822+ func testAccCheckRecordFilterCount (r * dns.Record , expected int ) resource.TestCheckFunc {
823+ return func (s * terraform.State ) error {
824+ if len (r .Filters ) != expected {
825+ return fmt .Errorf ("r.Filters, got: %d, want: %d" , len (r .Filters ), expected )
826+ }
827+
828+ return nil
829+ }
830+ }
831+
787832func testAccCheckRecordDestroy (s * terraform.State ) error {
788833 client := testAccProvider .Meta ().(* ns1.Client )
789834
@@ -1164,6 +1209,30 @@ resource "ns1_zone" "test" {
11641209` , rString )
11651210}
11661211
1212+ func testAccRecordUpdatedNoFilters (rString string ) string {
1213+ return fmt .Sprintf (`
1214+ resource "ns1_record" "it" {
1215+ zone = "${ns1_zone.test.zone}"
1216+ domain = "test.${ns1_zone.test.zone}"
1217+ type = "CNAME"
1218+ ttl = 60
1219+
1220+ answers {
1221+ answer = "test1.${ns1_zone.test.zone}"
1222+ region = "cal"
1223+ }
1224+
1225+ regions {
1226+ name = "cal"
1227+ }
1228+ }
1229+
1230+ resource "ns1_zone" "test" {
1231+ zone = "terraform-test-%s.io"
1232+ }
1233+ ` , rString )
1234+ }
1235+
11671236func testAccRecordAnswerMeta (rString string ) string {
11681237 return fmt .Sprintf (`
11691238resource "ns1_record" "it" {
0 commit comments