Skip to content

Commit

Permalink
Fix TestAccSqlUser_postgresIAM by using a real IAM user (#10731) (#18212
Browse files Browse the repository at this point in the history
)

[upstream:45be142d046f4aa453fd4d02c092508860718a0c]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored May 21, 2024
1 parent 204db4f commit ff106d3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions google/services/sql/resource_sql_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ func TestAccSqlUser_postgres(t *testing.T) {
}

func TestAccSqlUser_postgresIAM(t *testing.T) {
t.Skipf("Skipping test %s due to https://github.com/hashicorp/terraform-provider-google/issues/16704", t.Name())
t.Parallel()

instance := fmt.Sprintf("tf-test-%d", acctest.RandInt(t))
const iamUser = "admin@hashicorptest.com"
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Expand All @@ -151,14 +151,14 @@ func TestAccSqlUser_postgresIAM(t *testing.T) {
CheckDestroy: testAccSqlUserDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testGoogleSqlUser_postgresIAM(instance),
Config: testGoogleSqlUser_postgresIAM(instance, iamUser),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleSqlUserExists(t, "google_sql_user.user"),
),
},
{
ResourceName: "google_sql_user.user",
ImportStateId: fmt.Sprintf("%s/%s/admin", envvar.GetTestProjectFromEnv(), instance),
ImportStateId: fmt.Sprintf("%s/%s/%s", envvar.GetTestProjectFromEnv(), instance, iamUser),
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"password"},
Expand Down Expand Up @@ -406,7 +406,7 @@ resource "google_sql_user" "user" {
`, instance, password)
}

func testGoogleSqlUser_postgresIAM(instance string) string {
func testGoogleSqlUser_postgresIAM(instance, iamUser string) string {
return fmt.Sprintf(`
resource "google_sql_database_instance" "instance" {
name = "%s"
Expand All @@ -424,19 +424,19 @@ resource "google_sql_database_instance" "instance" {
}
# TODO: Remove with resolution of https://github.com/hashicorp/terraform-provider-google/issues/14233
resource "time_sleep" "wait_30_seconds" {
resource "time_sleep" "wait_60_seconds" {
depends_on = [google_sql_database_instance.instance]
create_duration = "30s"
create_duration = "60s"
}
resource "google_sql_user" "user" {
depends_on = [time_sleep.wait_30_seconds]
name = "admin"
depends_on = [time_sleep.wait_60_seconds]
name = "%s"
instance = google_sql_database_instance.instance.name
type = "CLOUD_IAM_USER"
}
`, instance)
`, instance, iamUser)
}

func testGoogleSqlUser_postgresAbandon(instance, name string) string {
Expand Down

0 comments on commit ff106d3

Please sign in to comment.