update A and CNAME data tests to ensure id is set

This commit is contained in:
S. Brent Faulkner 2017-05-07 11:41:18 -04:00
parent c732c3b16f
commit af64080153
2 changed files with 30 additions and 13 deletions

View File

@ -12,6 +12,7 @@ func TestAccDataDnsARecordSet_Basic(t *testing.T) {
DataSourceBlock string DataSourceBlock string
DataSourceName string DataSourceName string
Expected []string Expected []string
Host string
}{ }{
{ {
` `
@ -23,6 +24,7 @@ func TestAccDataDnsARecordSet_Basic(t *testing.T) {
[]string{ []string{
"127.0.0.1", "127.0.0.1",
}, },
"127.0.0.1.nip.io",
}, },
{ {
` `
@ -34,23 +36,30 @@ func TestAccDataDnsARecordSet_Basic(t *testing.T) {
[]string{ []string{
"129.6.15.30", "129.6.15.30",
}, },
"time-c.nist.gov",
}, },
} }
var steps []resource.TestStep
for _, test := range tests { for _, test := range tests {
ts := resource.TestStep{ recordName := fmt.Sprintf("data.dns_a_record_set.%s", test.DataSourceName)
resource.UnitTest(t, resource.TestCase{
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: test.DataSourceBlock, Config: test.DataSourceBlock,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testCheckAttrStringArray(fmt.Sprintf("data.dns_a_record_set.%s", test.DataSourceName), "addrs", test.Expected), testCheckAttrStringArray(recordName, "addrs", test.Expected),
), ),
} },
steps = append(steps, ts) resource.TestStep{
Config: test.DataSourceBlock,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(recordName, "id", test.Host),
),
},
},
})
} }
resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Steps: steps,
})
} }

View File

@ -10,6 +10,7 @@ func TestAccDnsCnameRecordSet_Basic(t *testing.T) {
tests := []struct { tests := []struct {
DataSourceBlock string DataSourceBlock string
Expected string Expected string
Host string
}{ }{
{ {
` `
@ -18,6 +19,7 @@ func TestAccDnsCnameRecordSet_Basic(t *testing.T) {
} }
`, `,
"dualstack.s.shared.global.fastly.net.", "dualstack.s.shared.global.fastly.net.",
"www.hashicorp.com",
}, },
} }
@ -31,6 +33,12 @@ func TestAccDnsCnameRecordSet_Basic(t *testing.T) {
r.TestCheckResourceAttr("data.dns_cname_record_set.foo", "cname", test.Expected), r.TestCheckResourceAttr("data.dns_cname_record_set.foo", "cname", test.Expected),
), ),
}, },
r.TestStep{
Config: test.DataSourceBlock,
Check: r.ComposeTestCheckFunc(
r.TestCheckResourceAttr("data.dns_cname_record_set.foo", "id", test.Host),
),
},
}, },
}) })
} }