Convert dns data tests to acceptance tests

These call out to external resources and can fail in unit tests.
This commit is contained in:
James Bardin 2017-03-17 12:02:40 -04:00
parent c9df11e32f
commit 983e041dc1
2 changed files with 17 additions and 14 deletions

View File

@ -4,10 +4,10 @@ import (
"fmt" "fmt"
"testing" "testing"
r "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
) )
func TestAccDnsARecordSet_Basic(t *testing.T) { func TestAccDataDnsARecordSet_Basic(t *testing.T) {
tests := []struct { tests := []struct {
DataSourceBlock string DataSourceBlock string
DataSourceName string DataSourceName string
@ -37,17 +37,20 @@ func TestAccDnsARecordSet_Basic(t *testing.T) {
}, },
} }
var steps []resource.TestStep
for _, test := range tests { for _, test := range tests {
r.UnitTest(t, r.TestCase{ ts := resource.TestStep{
Providers: testAccProviders,
Steps: []r.TestStep{
r.TestStep{
Config: test.DataSourceBlock, Config: test.DataSourceBlock,
Check: r.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testCheckAttrStringArray(fmt.Sprintf("data.dns_a_record_set.%s", test.DataSourceName), "addrs", test.Expected), testCheckAttrStringArray(fmt.Sprintf("data.dns_a_record_set.%s", test.DataSourceName), "addrs", test.Expected),
), ),
}, }
}, steps = append(steps, ts)
}
resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Steps: steps,
}) })
} }
}

View File

@ -10,7 +10,7 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
) )
func TestAccDnsARecordSet_basic(t *testing.T) { func TestAccDnsARecordSet_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },