@@ -2,21 +2,24 @@ package google
2
2
3
3
import (
4
4
"fmt"
5
+ "reflect"
6
+ "sort"
7
+ "testing"
8
+
5
9
"github.com/hashicorp/terraform/helper/resource"
6
10
"github.com/hashicorp/terraform/terraform"
7
11
"google.golang.org/api/cloudresourcemanager/v1"
8
- "reflect"
9
- "testing"
10
12
)
11
13
12
14
var DENIED_ORG_POLICIES = []string {
13
- "maps-ios-backend .googleapis.com" ,
14
- "placesios .googleapis.com" ,
15
+ "doubleclicksearch .googleapis.com" ,
16
+ "replicapoolupdater .googleapis.com" ,
15
17
}
16
18
17
- func TestAccGoogleOrganizationPolicy_boolean ( t * testing. T ) {
18
- t . Parallel ()
19
+ // Since each test here is acting on the same organization, run the tests serially to
20
+ // avoid race conditions and aborted operations.
19
21
22
+ func TestAccGoogleOrganizationPolicy_boolean (t * testing.T ) {
20
23
org := getTestOrgFromEnv (t )
21
24
resource .Test (t , resource.TestCase {
22
25
PreCheck : func () { testAccPreCheck (t ) },
@@ -58,8 +61,6 @@ func TestAccGoogleOrganizationPolicy_boolean(t *testing.T) {
58
61
}
59
62
60
63
func TestAccGoogleOrganizationPolicy_list_allowAll (t * testing.T ) {
61
- t .Parallel ()
62
-
63
64
org := getTestOrgFromEnv (t )
64
65
resource .Test (t , resource.TestCase {
65
66
PreCheck : func () { testAccPreCheck (t ) },
@@ -80,8 +81,6 @@ func TestAccGoogleOrganizationPolicy_list_allowAll(t *testing.T) {
80
81
}
81
82
82
83
func TestAccGoogleOrganizationPolicy_list_allowSome (t * testing.T ) {
83
- t .Parallel ()
84
-
85
84
org := getTestOrgFromEnv (t )
86
85
project := getTestProjectFromEnv ()
87
86
resource .Test (t , resource.TestCase {
@@ -103,8 +102,6 @@ func TestAccGoogleOrganizationPolicy_list_allowSome(t *testing.T) {
103
102
}
104
103
105
104
func TestAccGoogleOrganizationPolicy_list_denySome (t * testing.T ) {
106
- t .Parallel ()
107
-
108
105
org := getTestOrgFromEnv (t )
109
106
resource .Test (t , resource.TestCase {
110
107
PreCheck : func () { testAccPreCheck (t ) },
@@ -125,8 +122,6 @@ func TestAccGoogleOrganizationPolicy_list_denySome(t *testing.T) {
125
122
}
126
123
127
124
func TestAccGoogleOrganizationPolicy_list_update (t * testing.T ) {
128
- t .Parallel ()
129
-
130
125
org := getTestOrgFromEnv (t )
131
126
resource .Test (t , resource.TestCase {
132
127
PreCheck : func () { testAccPreCheck (t ) },
@@ -216,6 +211,8 @@ func testAccCheckGoogleOrganizationListPolicyAllowedValues(n string, values []st
216
211
return err
217
212
}
218
213
214
+ sort .Strings (policy .ListPolicy .AllowedValues )
215
+ sort .Strings (values )
219
216
if ! reflect .DeepEqual (policy .ListPolicy .AllowedValues , values ) {
220
217
return fmt .Errorf ("Expected the list policy to allow '%s', instead allowed '%s'" , values , policy .ListPolicy .AllowedValues )
221
218
}
@@ -231,6 +228,8 @@ func testAccCheckGoogleOrganizationListPolicyDeniedValues(n string, values []str
231
228
return err
232
229
}
233
230
231
+ sort .Strings (policy .ListPolicy .DeniedValues )
232
+ sort .Strings (values )
234
233
if ! reflect .DeepEqual (policy .ListPolicy .DeniedValues , values ) {
235
234
return fmt .Errorf ("Expected the list policy to deny '%s', instead denied '%s'" , values , policy .ListPolicy .DeniedValues )
236
235
}
@@ -306,13 +305,13 @@ func testAccGoogleOrganizationPolicy_list_denySome(org string) string {
306
305
return fmt .Sprintf (`
307
306
resource "google_organization_policy" "list" {
308
307
org_id = "%s"
309
- constraint = "serviceuser.services"
308
+ constraint = "serviceuser.services"
310
309
311
310
list_policy {
312
311
deny {
313
312
values = [
314
- "maps-ios-backend .googleapis.com",
315
- "placesios .googleapis.com",
313
+ "doubleclicksearch .googleapis.com",
314
+ "replicapoolupdater .googleapis.com",
316
315
]
317
316
}
318
317
}
0 commit comments