From bc5def9f8136003836911e78567dc8849a39be6d Mon Sep 17 00:00:00 2001 From: thokalavinod Date: Wed, 21 Aug 2024 16:53:32 +0000 Subject: [PATCH] Fix test `TestAccSecurityCenterManagementOrganizationEventThreatDetectionCustomModule` (#11469) --- ...ity_health_analytics_custom_module_test.go | 3 +-- ...ent_threat_detection_custom_module_test.go | 24 +++++++++++++++++-- ...ity_health_analytics_custom_module_test.go | 3 +-- ...ity_health_analytics_custom_module_test.go | 3 +-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go index d7798136e117..6dd5dd4a491e 100644 --- a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go +++ b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_test.go @@ -16,8 +16,7 @@ import ( // Custom Module tests cannot be run in parallel without running into 409 Conflict reponses. // Run them as individual steps of an update test instead. -func TestAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule(t *testing.T) { - t.Parallel() +func testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule(t *testing.T) { context := map[string]interface{}{ "org_id": envvar.GetTestOrgFromEnv(t), diff --git a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_test.go b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_test.go index f89bb92782f8..aa3afe0781cf 100644 --- a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_test.go +++ b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_test.go @@ -14,8 +14,28 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" ) -func TestAccSecurityCenterManagementOrganizationEventThreatDetectionCustomModule(t *testing.T) { - t.Parallel() +func TestAccSecurityCenterManagement(t *testing.T) { + testCases := map[string]func(t *testing.T){ + "orgSecurity": testAccSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule, + "folderSecurity": testAccSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule, + "projectSecurity": testAccSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule, + "organization": testAccSecurityCenterManagementOrganizationEventThreatDetectionCustomModule, + } + + 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 testAccSecurityCenterManagementOrganizationEventThreatDetectionCustomModule(t *testing.T) { + // t.Parallel() context := map[string]interface{}{ "org_id": envvar.GetTestOrgFromEnv(t), diff --git a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_project_security_health_analytics_custom_module_test.go b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_project_security_health_analytics_custom_module_test.go index b438d13567a8..0edd70f41a48 100644 --- a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_project_security_health_analytics_custom_module_test.go +++ b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_project_security_health_analytics_custom_module_test.go @@ -15,8 +15,7 @@ import ( // Custom Module tests cannot be run in parallel without running into 409 Conflict reponses. // Run them as individual steps of an update test instead. -func TestAccSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule(t *testing.T) { - t.Parallel() +func testAccSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule(t *testing.T) { context := map[string]interface{}{ "random_suffix": acctest.RandString(t, 10), diff --git a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_test.go b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_test.go index caf332c1667d..fdd2dcba60f6 100644 --- a/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_test.go +++ b/mmv1/third_party/terraform/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_test.go @@ -16,8 +16,7 @@ import ( // Custom Module tests cannot be run in parallel without running into 409 Conflict reponses. // Run them as individual steps of an update test instead. -func TestAccSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule(t *testing.T) { - t.Parallel() +func testAccSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule(t *testing.T) { context := map[string]interface{}{ "org_id": envvar.GetTestOrgFromEnv(t),