Skip to content

Commit

Permalink
Fix sql VCR test failure in replaying (#6625) (#12686)
Browse files Browse the repository at this point in the history
* prevent TestAccSqlDatabaseInstance_mysqlMajorVersionUpgrade from failing in VCR replaying mode

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Sep 29, 2022
1 parent 1002330 commit 4ffd911
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .changelog/6625.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```release-note:none
```
17 changes: 11 additions & 6 deletions google/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1275,13 +1275,16 @@ func TestAccSqlDatabaseInstance_SqlServerAuditConfig(t *testing.T) {
func TestAccSqlDatabaseInstance_mysqlMajorVersionUpgrade(t *testing.T) {
t.Parallel()

databaseName := "tf-test-" + randString(t, 10)

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testGoogleSqlDatabaseInstance_basic2,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_basic3, databaseName),
},
{
ResourceName: "google_sql_database_instance.instance",
Expand All @@ -1290,7 +1293,8 @@ func TestAccSqlDatabaseInstance_mysqlMajorVersionUpgrade(t *testing.T) {
ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"},
},
{
Config: testGoogleSqlDatabaseInstance_basic2_update,
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_basic3_update, databaseName),
},
{
ResourceName: "google_sql_database_instance.instance",
Expand Down Expand Up @@ -1360,22 +1364,23 @@ resource "google_sql_database_instance" "instance" {
}
`

var testGoogleSqlDatabaseInstance_basic2_update = `
var testGoogleSqlDatabaseInstance_basic3 = `
resource "google_sql_database_instance" "instance" {
name = "%s"
region = "us-central1"
database_version = "MYSQL_8_0"
database_version = "MYSQL_5_7"
deletion_protection = false
settings {
tier = "db-f1-micro"
}
}
`

var testGoogleSqlDatabaseInstance_basic3 = `
var testGoogleSqlDatabaseInstance_basic3_update = `
resource "google_sql_database_instance" "instance" {
name = "%s"
region = "us-central1"
database_version = "MYSQL_5_7"
database_version = "MYSQL_8_0"
deletion_protection = false
settings {
tier = "db-f1-micro"
Expand Down

0 comments on commit 4ffd911

Please sign in to comment.