From 8d44f3a05de0f1e38029f3e739056b4159a85bbb Mon Sep 17 00:00:00 2001 From: Roberto Jung Drebes Date: Mon, 12 Nov 2018 21:53:14 +0100 Subject: [PATCH] reintroduce dns_managed_zone autogen test for terraform --- products/dns/terraform.yaml | 17 +++----- .../examples/dns_managed_zone_basic.tf.erb | 12 ++++++ .../tests/resource_dns_managed_zone_test.go | 41 ------------------- 3 files changed, 18 insertions(+), 52 deletions(-) create mode 100644 templates/terraform/examples/dns_managed_zone_basic.tf.erb diff --git a/products/dns/terraform.yaml b/products/dns/terraform.yaml index 003c3e3f687a..2a807e5ecc04 100644 --- a/products/dns/terraform.yaml +++ b/products/dns/terraform.yaml @@ -14,17 +14,11 @@ --- !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 @@ -32,6 +26,7 @@ overrides: !ruby/object:Provider::ResourceOverrides 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 diff --git a/templates/terraform/examples/dns_managed_zone_basic.tf.erb b/templates/terraform/examples/dns_managed_zone_basic.tf.erb new file mode 100644 index 000000000000..8ecbb4ae821a --- /dev/null +++ b/templates/terraform/examples/dns_managed_zone_basic.tf.erb @@ -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 +} diff --git a/third_party/terraform/tests/resource_dns_managed_zone_test.go b/third_party/terraform/tests/resource_dns_managed_zone_test.go index 372f2221b350..8d27ed580ce4 100644 --- a/third_party/terraform/tests/resource_dns_managed_zone_test.go +++ b/third_party/terraform/tests/resource_dns_managed_zone_test.go @@ -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() @@ -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" {