Skip to content

Commit 1f2f81c

Browse files
committed
2 parents f234ac8 + 745aa1b commit 1f2f81c

2 files changed

Lines changed: 24 additions & 15 deletions

File tree

mmv1/third_party/terraform/services/accessapproval/resource_access_approval_organization_settings_test.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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
1717
func 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

8082
func 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

mmv1/third_party/terraform/services/storage/resource_storage_object_acl_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ func (t *testRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
302302
if err != nil {
303303
return response, err
304304
}
305-
expectedPath := fmt.Sprintf("/storage/v1/b/%s/o/%s", t.bucketName, t.objectName)
306-
if t.done || r.URL.Path != expectedPath || r.Host != "storage.googleapis.com" {
305+
if !r.URL.Query().Has("projection") || response.StatusCode != http.StatusOK {
307306
return response, err
308307
}
309308
t.done = true
@@ -366,6 +365,7 @@ func TestAccStorageObjectAcl_noOwner(t *testing.T) {
366365
{
367366
Config: testGoogleStorageObjectsAclBasic1(bucketName, objectName),
368367
ExpectNonEmptyPlan: true,
368+
PlanOnly: true,
369369
},
370370
},
371371
})

0 commit comments

Comments
 (0)