@@ -76,6 +76,33 @@ func TestAccDigitalOceanRecord_Updated(t *testing.T) {
7676 })
7777}
7878
79+ func TestAccDigitalOceanRecord_HostnameValue (t * testing.T ) {
80+ var record digitalocean.Record
81+
82+ resource .Test (t , resource.TestCase {
83+ PreCheck : func () { testAccPreCheck (t ) },
84+ Providers : testAccProviders ,
85+ CheckDestroy : testAccCheckDigitalOceanRecordDestroy ,
86+ Steps : []resource.TestStep {
87+ resource.TestStep {
88+ Config : testAccCheckDigitalOceanRecordConfig_cname ,
89+ Check : resource .ComposeTestCheckFunc (
90+ testAccCheckDigitalOceanRecordExists ("digitalocean_record.foobar" , & record ),
91+ testAccCheckDigitalOceanRecordAttributesHostname (& record ),
92+ resource .TestCheckResourceAttr (
93+ "digitalocean_record.foobar" , "name" , "terraform" ),
94+ resource .TestCheckResourceAttr (
95+ "digitalocean_record.foobar" , "domain" , "foobar-test-terraform.com" ),
96+ resource .TestCheckResourceAttr (
97+ "digitalocean_record.foobar" , "value" , "a.foobar-test-terraform.com" ),
98+ resource .TestCheckResourceAttr (
99+ "digitalocean_record.foobar" , "type" , "CNAME" ),
100+ ),
101+ },
102+ },
103+ })
104+ }
105+
79106func testAccCheckDigitalOceanRecordDestroy (s * terraform.State ) error {
80107 client := testAccProvider .Meta ().(* digitalocean.Client )
81108
@@ -146,6 +173,17 @@ func testAccCheckDigitalOceanRecordExists(n string, record *digitalocean.Record)
146173 }
147174}
148175
176+ func testAccCheckDigitalOceanRecordAttributesHostname (record * digitalocean.Record ) resource.TestCheckFunc {
177+ return func (s * terraform.State ) error {
178+
179+ if record .Data != "a.foobar-test-terraform.com" {
180+ return fmt .Errorf ("Bad value: %s" , record .Data )
181+ }
182+
183+ return nil
184+ }
185+ }
186+
149187const testAccCheckDigitalOceanRecordConfig_basic = `
150188resource "digitalocean_domain" "foobar" {
151189 name = "foobar-test-terraform.com"
@@ -173,3 +211,17 @@ resource "digitalocean_record" "foobar" {
173211 value = "192.168.0.11"
174212 type = "A"
175213}`
214+
215+ const testAccCheckDigitalOceanRecordConfig_cname = `
216+ resource "digitalocean_domain" "foobar" {
217+ name = "foobar-test-terraform.com"
218+ ip_address = "192.168.0.10"
219+ }
220+
221+ resource "digitalocean_record" "foobar" {
222+ domain = "${digitalocean_domain.foobar.name}"
223+
224+ name = "terraform"
225+ value = "a.foobar-test-terraform.com"
226+ type = "CNAME"
227+ }`
0 commit comments