diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index edab4133c7de..908621eb7484 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -22,6 +22,13 @@ func TestAccSpannerDatabase_basic(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckSpannerDatabaseDestroyProducer(t), Steps: []resource.TestStep{ + { + Config: testAccSpannerDatabase_virtualUpdate(instanceName, databaseName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("google_spanner_database.basic", "state"), + resource.TestCheckResourceAttr("google_spanner_database.basic", "version_retention_period", "1h"), // default set by API + ), + }, { Config: testAccSpannerDatabase_basic(instanceName, databaseName), Check: resource.ComposeTestCheckFunc( @@ -120,6 +127,27 @@ resource "google_spanner_database" "basic" { `, instanceName, instanceName, databaseName) } +func testAccSpannerDatabase_virtualUpdate(instanceName, databaseName string) string { + return fmt.Sprintf(` +resource "google_spanner_instance" "basic" { + name = "%s" + config = "regional-us-central1" + display_name = "%s-display" + num_nodes = 1 +} + +resource "google_spanner_database" "basic" { + instance = google_spanner_instance.basic.name + name = "%s" + ddl = [ + "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)", + "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)", + ] + deletion_protection = true +} +`, instanceName, instanceName, databaseName) +} + func TestAccSpannerDatabase_postgres(t *testing.T) { t.Parallel() diff --git a/mmv1/third_party/terraform/tests/resource_spanner_instance_test.go b/mmv1/third_party/terraform/tests/resource_spanner_instance_test.go index 334428b6e6a9..96ef417b1e17 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_instance_test.go +++ b/mmv1/third_party/terraform/tests/resource_spanner_instance_test.go @@ -147,6 +147,35 @@ func TestAccSpannerInstance_update(t *testing.T) { }) } +func TestAccSpannerInstance_virtualUpdate(t *testing.T) { + // Randomness + skipIfVcr(t) + t.Parallel() + + dName := fmt.Sprintf("spanner-dname1-%s", randString(t, 10)) + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckSpannerInstanceDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccSpannerInstance_virtualUpdate(dName, "true"), + }, + { + ResourceName: "google_spanner_instance.basic", + ImportState: true, + }, + { + Config: testAccSpannerInstance_virtualUpdate(dName, "false"), + }, + { + ResourceName: "google_spanner_instance.basic", + ImportState: true, + }, + }, + }) +} + func testAccSpannerInstance_basic(name string) string { return fmt.Sprintf(` resource "google_spanner_instance" "basic" { @@ -196,3 +225,15 @@ resource "google_spanner_instance" "updater" { } `, name, nodes, extraLabel) } + +func testAccSpannerInstance_virtualUpdate(name, virtual string) string { + return fmt.Sprintf(` +resource "google_spanner_instance" "basic" { + name = "%s" + config = "regional-us-central1" + display_name = "%s" + processing_units = 100 + force_destroy = "%s" +} +`, name, name, virtual) +}