mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
![Paddy Carver](/assets/img/avatar_default.png)
Move from using qa.test.com, a domain we don't own, to qa.tf-test.club, a domain we do own, so the domain validation doesn't cause our tests to fail anymore.
74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
func TestAccDataSourceDnsManagedZone_basic(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckDnsManagedZoneDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccDataSourceDnsManagedZone_basic(),
|
|
Check: testAccDataSourceDnsManagedZoneCheck("data.google_dns_managed_zone.qa", "google_dns_managed_zone.foo"),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccDataSourceDnsManagedZoneCheck(dsName, rsName string) resource.TestCheckFunc {
|
|
return func(s *terraform.State) error {
|
|
ds, ok := s.RootModule().Resources[rsName]
|
|
if !ok {
|
|
return fmt.Errorf("can't find resource called %s in state", rsName)
|
|
}
|
|
|
|
rs, ok := s.RootModule().Resources[dsName]
|
|
if !ok {
|
|
return fmt.Errorf("can't find data source called %s in state", dsName)
|
|
}
|
|
|
|
dsAttr := ds.Primary.Attributes
|
|
rsAttr := rs.Primary.Attributes
|
|
|
|
attrsToTest := []string{
|
|
"id",
|
|
"name",
|
|
"description",
|
|
"dns_name",
|
|
"name_servers",
|
|
}
|
|
|
|
for _, attrToTest := range attrsToTest {
|
|
if dsAttr[attrToTest] != rsAttr[attrToTest] {
|
|
return fmt.Errorf("%s is %s; want %s", attrToTest, dsAttr[attrToTest], rsAttr[attrToTest])
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func testAccDataSourceDnsManagedZone_basic() string {
|
|
return fmt.Sprintf(`
|
|
resource "google_dns_managed_zone" "foo" {
|
|
name = "qa-zone-%s"
|
|
dns_name = "qa.tf-test.club."
|
|
description = "QA DNS zone"
|
|
}
|
|
|
|
data "google_dns_managed_zone" "qa" {
|
|
name = "${google_dns_managed_zone.foo.name}"
|
|
}
|
|
`, acctest.RandString(10))
|
|
}
|