terraform-provider-google/google/resource_filestore_instance_generated_test.go
The Magician 63216b0c90 Mark Filestore as GA (#3522)
Signed-off-by: Modular Magician <magic-modules@google.com>
2019-05-02 10:29:08 -07:00

96 lines
2.4 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"
"strings"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccFilestoreInstance_filestoreInstanceBasicExample(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"random_suffix": acctest.RandString(10),
}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFilestoreInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstance_filestoreInstanceBasicExample(context),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"zone"},
},
},
})
}
func testAccFilestoreInstance_filestoreInstanceBasicExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_filestore_instance" "instance" {
name = "test-instance-%{random_suffix}"
zone = "us-central1-b"
tier = "PREMIUM"
file_shares {
capacity_gb = 2660
name = "share1"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
}
}
`, context)
}
func testAccCheckFilestoreInstanceDestroy(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
if rs.Type != "google_filestore_instance" {
continue
}
if strings.HasPrefix(name, "data.") {
continue
}
config := testAccProvider.Meta().(*Config)
url, err := replaceVarsForTest(rs, "https://file.googleapis.com/v1/projects/{{project}}/locations/{{zone}}/instances/{{name}}")
if err != nil {
return err
}
_, err = sendRequest(config, "GET", url, nil)
if err == nil {
return fmt.Errorf("FilestoreInstance still exists at %s", url)
}
}
return nil
}