Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combine all access approval tests to run serially #7535

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4104.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
7 changes: 4 additions & 3 deletions google/resource_access_approval_folder_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func TestAccAccessApprovalFolderSettings_update(t *testing.T) {
t.Parallel()

// Since access approval settings are heirarchical, and only one can exist per folder/project/org,
// and all refer to the same organization, they need to be ran serially
// See AccessApprovalOrganizationSettings for the test runner.
func testAccAccessApprovalFolderSettings(t *testing.T) {
context := map[string]interface{}{
"org_id": getTestOrgFromEnv(t),
"random_suffix": randString(t, 10),
Expand Down
23 changes: 21 additions & 2 deletions google/resource_access_approval_organization_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func TestAccAccessApprovalOrganizationSettings_update(t *testing.T) {
t.Parallel()
// Since access approval settings are heirarchical, and only one can exist per folder/project/org,
// and all refer to the same organization, they need to be ran serially
func TestAccAccessApprovalSettings(t *testing.T) {
testCases := map[string]func(t *testing.T){
"folder": testAccAccessApprovalFolderSettings,
"project": testAccAccessApprovalProjectSettings,
"organization": testAccAccessApprovalOrganizationSettings,
}

for name, tc := range testCases {
// shadow the tc variable into scope so that when
// the loop continues, if t.Run hasn't executed tc(t)
// yet, we don't have a race condition
// see https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loop-iterator-variables
tc := tc
t.Run(name, func(t *testing.T) {
tc(t)
})
}
}

func testAccAccessApprovalOrganizationSettings(t *testing.T) {
context := map[string]interface{}{
"org_id": getTestOrgFromEnv(t),
"random_suffix": randString(t, 10),
Expand Down
7 changes: 4 additions & 3 deletions google/resource_access_approval_project_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func TestAccAccessApprovalProjectSettings_update(t *testing.T) {
t.Parallel()

// Since access approval settings are heirarchical, and only one can exist per folder/project/org,
// and all refer to the same organization, they need to be ran serially.
// See AccessApprovalOrganizationSettings for the test runner.
func testAccAccessApprovalProjectSettings(t *testing.T) {
context := map[string]interface{}{
"project": getTestProjectFromEnv(),
"org_id": getTestOrgFromEnv(t),
Expand Down