blob: 6939396b1979064be7030eaedb53f1f00af7fac4 [file] [log] [blame]
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package notebooks_test
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
)
func TestAccNotebooksInstance_state(t *testing.T) {
t.Parallel()
prefix := fmt.Sprintf("%d", acctest.RandInt(t))
name := fmt.Sprintf("tf-%s", prefix)
acctest.VcrTest(t, resource.TestCase{
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccNotebooksInstance_basic_active(name),
},
{
ResourceName: "google_notebooks_instance.test",
ImportState: true,
ImportStateVerify: true,
ExpectNonEmptyPlan: true,
ImportStateVerifyIgnore: []string{"container_image", "metadata", "vm_image", "desired_state", "update_time"},
},
{
Config: testAccNotebooksInstance_basic_stopped(name),
},
{
ResourceName: "google_notebooks_instance.test",
ImportState: true,
ImportStateVerify: true,
ExpectNonEmptyPlan: true,
ImportStateVerifyIgnore: []string{"container_image", "metadata", "vm_image", "desired_state", "update_time"},
},
{
Config: testAccNotebooksInstance_basic_active(name),
},
{
ResourceName: "google_notebooks_instance.test",
ImportState: true,
ImportStateVerify: true,
ExpectNonEmptyPlan: true,
ImportStateVerifyIgnore: []string{"container_image", "metadata", "vm_image", "desired_state", "update_time"},
},
},
})
}
func testAccNotebooksInstance_basic_active(name string) string {
return fmt.Sprintf(`
resource "google_notebooks_instance" "test" {
name = "%s"
location = "us-west1-a"
machine_type = "e2-medium"
vm_image {
project = "deeplearning-platform-release"
image_family = "tf-latest-cpu"
}
desired_state = "ACTIVE"
}
`, name)
}
func testAccNotebooksInstance_basic_stopped(name string) string {
return fmt.Sprintf(`
resource "google_notebooks_instance" "test" {
name = "%s"
location = "us-west1-a"
machine_type = "e2-medium"
vm_image {
project = "deeplearning-platform-release"
image_family = "tf-latest-cpu"
}
desired_state = "STOPPED"
}
`, name)
}