mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
85 lines
2.1 KiB
Go
85 lines
2.1 KiB
Go
![]() |
// ----------------------------------------------------------------------------
|
||
|
//
|
||
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
||
|
//
|
||
|
// ----------------------------------------------------------------------------
|
||
|
//
|
||
|
// This file is automatically generated by Magic Modules and manual
|
||
|
// changes will be clobbered when the file is regenerated.
|
||
|
//
|
||
|
// Please read more about how to change this file in
|
||
|
// .github/CONTRIBUTING.md.
|
||
|
//
|
||
|
// ----------------------------------------------------------------------------
|
||
|
|
||
|
package google
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||
|
"github.com/hashicorp/terraform/helper/resource"
|
||
|
"github.com/hashicorp/terraform/terraform"
|
||
|
)
|
||
|
|
||
|
func TestAccDnsManagedZone_dnsManagedZoneBasicExample(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
resource.Test(t, resource.TestCase{
|
||
|
PreCheck: func() { testAccPreCheck(t) },
|
||
|
Providers: testAccProviders,
|
||
|
CheckDestroy: testAccCheckDnsManagedZoneDestroy,
|
||
|
Steps: []resource.TestStep{
|
||
|
{
|
||
|
Config: testAccDnsManagedZone_dnsManagedZoneBasicExample(acctest.RandString(10)),
|
||
|
},
|
||
|
{
|
||
|
ResourceName: "google_dns_managed_zone.example-zone",
|
||
|
ImportState: true,
|
||
|
ImportStateVerify: true,
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testAccDnsManagedZone_dnsManagedZoneBasicExample(val string) string {
|
||
|
return fmt.Sprintf(`
|
||
|
resource "google_dns_managed_zone" "example-zone" {
|
||
|
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
|
||
|
}
|
||
|
`,
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func testAccCheckDnsManagedZoneDestroy(s *terraform.State) error {
|
||
|
for _, rs := range s.RootModule().Resources {
|
||
|
if rs.Type != "google_dns_managed_zone" {
|
||
|
continue
|
||
|
}
|
||
|
|
||
|
config := testAccProvider.Meta().(*Config)
|
||
|
|
||
|
url, err := replaceVarsForTest(rs, "https://www.googleapis.com/dns/v1/projects/{{project}}/managedZones/{{name}}")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
_, err = sendRequest(config, "GET", url, nil)
|
||
|
if err == nil {
|
||
|
return fmt.Errorf("DnsManagedZone still exists at %s", url)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|