From e89b7c0c42158bed0eb978e2b9b080eb99335bf9 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Fri, 29 Oct 2021 15:31:13 +0000 Subject: [PATCH] Try to deflake billing IAM test (#5387) Signed-off-by: Modular Magician --- .changelog/5387.txt | 2 ++ .../resource_google_billing_account_iam_test.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .changelog/5387.txt diff --git a/.changelog/5387.txt b/.changelog/5387.txt new file mode 100644 index 00000000000..e4e22fc1e47 --- /dev/null +++ b/.changelog/5387.txt @@ -0,0 +1,2 @@ +```release-note:none +``` diff --git a/google/resource_google_billing_account_iam_test.go b/google/resource_google_billing_account_iam_test.go index c7f6a16a89b..545e14ec232 100644 --- a/google/resource_google_billing_account_iam_test.go +++ b/google/resource_google_billing_account_iam_test.go @@ -49,6 +49,12 @@ func TestAccBillingAccountIam(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + // Remove the binding from state before adding a member. + // Otherwise, we'll process the delete and create in an arbitrary order + // and may have inconsistent results + Config: testAccBillingAccountNoBindings(account), + }, { // Test Iam Member creation (no update for member, no need to test) Config: testAccBillingAccountIamMember_basic(account, billing, role), @@ -125,6 +131,15 @@ func testAccCheckGoogleBillingAccountIamMemberExists(t *testing.T, n, role, memb } } +func testAccBillingAccountNoBindings(account string) string { + return fmt.Sprintf(` +resource "google_service_account" "test-account" { + account_id = "%s" + display_name = "Billing Account Iam Testing Account" +} +`, account) +} + func testAccBillingAccountIamBinding_basic(account, billingAccountId, role string) string { return fmt.Sprintf(` resource "google_service_account" "test-account" {