Skip to content

Commit

Permalink
reintroduce dns_managed_zone autogen test for terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
drebes committed Nov 16, 2018
1 parent f63c8e0 commit 8d44f3a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 52 deletions.
17 changes: 6 additions & 11 deletions products/dns/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,19 @@
--- !ruby/object:Provider::Terraform::Config
overrides: !ruby/object:Provider::ResourceOverrides
ManagedZone: !ruby/object:Provider::Terraform::ResourceOverride
examples: |
```hcl
resource "google_dns_managed_zone" "prod" {
name = "prod-zone"
dns_name = "prod.mydomain.com."
description = "Production DNS zone"
labels = {
foo = "bar"
}
}
```
example:
- !ruby/object:Provider::Terraform::Examples
name: "dns_managed_zone_basic"
primary_resource_id: "example-zone"
version: <%= _version_name %>
properties:
creationTime: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
description: !ruby/object:Provider::Terraform::PropertyOverride
description: |
A textual description field. Defaults to 'Managed by Terraform'.
default_value: 'Managed by Terraform'
required: false
id: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
nameServerSet: !ruby/object:Provider::Terraform::PropertyOverride
Expand Down
12 changes: 12 additions & 0 deletions templates/terraform/examples/dns_managed_zone_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_dns_managed_zone" "<%= ctx[:primary_resource_id] %>" {
name = "example-zone"
dns_name = "example-${random_id.rnd.hex}.com."
description = "Example DNS zone"
labels = {
foo = "bar"
}
}

resource "random_id" "rnd" {
byte_length = 4
}
41 changes: 0 additions & 41 deletions third_party/terraform/tests/resource_dns_managed_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,8 @@ import (

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)

func TestAccDnsManagedZone_basic(t *testing.T) {
t.Parallel()

zoneSuffix := acctest.RandString(10)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDnsManagedZoneDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDnsManagedZone_basic(zoneSuffix, "description1"),
},
resource.TestStep{
ResourceName: "google_dns_managed_zone.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccDnsManagedZone_update(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -61,24 +38,6 @@ func TestAccDnsManagedZone_update(t *testing.T) {
})
}

func testAccCheckDnsManagedZoneDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)

for _, rs := range s.RootModule().Resources {
if rs.Type != "google_dns_zone" {
continue
}

_, err := config.clientDns.ManagedZones.Get(
config.Project, rs.Primary.ID).Do()
if err == nil {
return fmt.Errorf("DNS ManagedZone still exists")
}
}

return nil
}

func testAccDnsManagedZone_basic(suffix, description string) string {
return fmt.Sprintf(`
resource "google_dns_managed_zone" "foobar" {
Expand Down

0 comments on commit 8d44f3a

Please sign in to comment.