terraform-provider-google/google/resource_compute_disk_generated_test.go
The Magician 2ab6d1995f Add = to map declarations in examples/tests (#2755)
<!-- This change is generated by MagicModules. -->
/cc @rileykarson
2018-12-27 07:51:23 -08:00

82 lines
2.0 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 TestAccComputeDisk_diskBasicExample(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeDiskDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeDisk_diskBasicExample(acctest.RandString(10)),
},
{
ResourceName: "google_compute_disk.default",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccComputeDisk_diskBasicExample(val string) string {
return fmt.Sprintf(`
resource "google_compute_disk" "default" {
name = "test-disk-%s"
type = "pd-ssd"
zone = "us-central1-a"
image = "debian-8-jessie-v20170523"
labels = {
environment = "dev"
}
}
`, val,
)
}
func testAccCheckComputeDiskDestroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
if rs.Type != "google_compute_disk" {
continue
}
config := testAccProvider.Meta().(*Config)
url, err := replaceVarsForTest(rs, "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/disks/{{name}}")
if err != nil {
return err
}
_, err = sendRequest(config, "GET", url, nil)
if err == nil {
return fmt.Errorf("ComputeDisk still exists at %s", url)
}
}
return nil
}