@@ -15,20 +15,19 @@ import (
1515// Since access approval settings are hierarchical, and only one can exist per folder/project/org,
1616// and all refer to the same organization, they need to be run serially
1717func TestAccAccessApprovalSettings (t * testing.T ) {
18- testCases := map [string ]func (t * testing.T ){
19- "folder" : testAccAccessApprovalFolderSettings ,
20- "project" : testAccAccessApprovalProjectSettings ,
21- "organization" : testAccAccessApprovalOrganizationSettings ,
18+ testCases := []struct {
19+ name string
20+ fn func (t * testing.T )
21+ }{
22+ {"organization" , testAccAccessApprovalOrganizationSettings },
23+ {"folder" , testAccAccessApprovalFolderSettings },
24+ {"project" , testAccAccessApprovalProjectSettings },
2225 }
2326
24- for name , tc := range testCases {
25- // shadow the tc variable into scope so that when
26- // the loop continues, if t.Run hasn't executed tc(t)
27- // yet, we don't have a race condition
28- // see https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loop-iterator-variables
27+ for _ , tc := range testCases {
2928 tc := tc
30- t .Run (name , func (t * testing.T ) {
31- tc (t )
29+ t .Run (tc . name , func (t * testing.T ) {
30+ tc . fn (t )
3231 })
3332 }
3433}
@@ -44,7 +43,10 @@ func testAccAccessApprovalOrganizationSettings(t *testing.T) {
4443 acctest .VcrTest (t , resource.TestCase {
4544 PreCheck : func () { acctest .AccTestPreCheck (t ) },
4645 ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
47- CheckDestroy : testAccCheckAccessApprovalOrganizationSettingsDestroyProducer (t ),
46+ ExternalProviders : map [string ]resource.ExternalProvider {
47+ "time" : {},
48+ },
49+ CheckDestroy : testAccCheckAccessApprovalOrganizationSettingsDestroyProducer (t ),
4850 Steps : []resource.TestStep {
4951 {
5052 Config : testAccAccessApprovalOrganizationSettings_full (context ),
@@ -79,7 +81,7 @@ func testAccAccessApprovalOrganizationSettings(t *testing.T) {
7981
8082func testAccAccessApprovalOrganizationSettings_full (context map [string ]interface {}) string {
8183 return acctest .Nprintf (`
82- resource "google_organization_access_approval_settings" "organization_access_approval" {
84+ resource "google_organization_access_approval_settings" "organization_access_approval" {
8385 organization_id = "%{org_id}"
8486 notification_emails = ["testuser@example.com"]
8587
@@ -92,6 +94,13 @@ resource "google_organization_access_approval_settings" "organization_access_app
9294 enrollment_level = "BLOCK_ALL"
9395 }
9496}
97+
98+ resource "time_sleep" "wait_120_seconds" {
99+ depends_on = [google_organization_access_approval_settings.organization_access_approval]
100+
101+ create_duration = "120s"
102+ }
103+
95104` , context )
96105}
97106
0 commit comments