Skip to content

Commit 7220c1d

Browse files
VCR acc test fixes (#3586) (#2130)
* Test commit * Test commit * Fix a couple more tests * Wrong method name * Fix more tests * Ordering of getting service account * Skip fine-grained test * Skip iam test with fine-grained Signed-off-by: Modular Magician <[email protected]>
1 parent 5ed5ea4 commit 7220c1d

10 files changed

+22
-4
lines changed

.changelog/3586.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/iam_storage_bucket_generated_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ func TestAccStorageBucketIamMemberGenerated(t *testing.T) {
9191
func TestAccStorageBucketIamPolicyGenerated(t *testing.T) {
9292
t.Parallel()
9393

94+
// This may skip test, so do it first
95+
sa := getTestServiceAccountFromEnv(t)
9496
context := map[string]interface{}{
9597
"random_suffix": randString(t, 10),
9698
"role": "roles/storage.objectViewer",
9799
"admin_role": "roles/storage.admin",
98100
"condition_title": "expires_after_2019_12_31",
99101
"condition_expr": `request.time < timestamp(\"2020-01-01T00:00:00Z\")`,
100102
}
101-
context["service_account"] = getTestServiceAccountFromEnv(t)
103+
context["service_account"] = sa
102104

103105
vcrTest(t, resource.TestCase{
104106
PreCheck: func() { testAccPreCheck(t) },
@@ -253,14 +255,16 @@ func TestAccStorageBucketIamMemberGenerated_withAndWithoutCondition(t *testing.T
253255
func TestAccStorageBucketIamPolicyGenerated_withCondition(t *testing.T) {
254256
t.Parallel()
255257

258+
// This may skip test, so do it first
259+
sa := getTestServiceAccountFromEnv(t)
256260
context := map[string]interface{}{
257261
"random_suffix": randString(t, 10),
258262
"role": "roles/storage.objectViewer",
259263
"admin_role": "roles/storage.admin",
260264
"condition_title": "expires_after_2019_12_31",
261265
"condition_expr": `request.time < timestamp(\"2020-01-01T00:00:00Z\")`,
262266
}
263-
context["service_account"] = getTestServiceAccountFromEnv(t)
267+
context["service_account"] = sa
264268

265269
vcrTest(t, resource.TestCase{
266270
PreCheck: func() { testAccPreCheck(t) },

google-beta/resource_bigquery_table_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestAccBigQueryTable_HivePartitioning(t *testing.T) {
7171
datasetID := fmt.Sprintf("tf_test_%s", randString(t, 10))
7272
tableID := fmt.Sprintf("tf_test_%s", randString(t, 10))
7373

74-
resource.Test(t, resource.TestCase{
74+
vcrTest(t, resource.TestCase{
7575
PreCheck: func() { testAccPreCheck(t) },
7676
Providers: testAccProviders,
7777
CheckDestroy: testAccCheckBigQueryTableDestroyProducer(t),

google-beta/resource_compute_instance_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ func testAccComputeInstance_disks_kms(pid string, bootEncryptionKey string, disk
30763076
for k := range diskNameToEncryptionKey {
30773077
diskNames = append(diskNames, k)
30783078
}
3079+
sort.Strings(diskNames)
30793080
return fmt.Sprintf(`
30803081
data "google_project" "project" {
30813082
project_id = "%s"

google-beta/resource_compute_project_metadata_item_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ func TestAccComputeProjectMetadataItem_basic(t *testing.T) {
3333
}
3434

3535
func TestAccComputeProjectMetadataItem_basicMultiple(t *testing.T) {
36+
// Multiple fine grained items applied in same config
37+
skipIfVcr(t)
3638
t.Parallel()
3739

3840
// Generate a config of two config keys

google-beta/resource_dataproc_cluster_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ func TestAccDataprocCluster_withLabels(t *testing.T) {
626626
}
627627

628628
func TestAccDataprocCluster_withNetworkRefs(t *testing.T) {
629+
// Multiple fine-grained resources
630+
skipIfVcr(t)
629631
t.Parallel()
630632

631633
var c1, c2 dataproc.Cluster

google-beta/resource_google_billing_account_iam_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
)
1212

1313
func TestAccBillingAccountIam(t *testing.T) {
14+
// Deletes two fine-grained resources in same step
15+
skipIfVcr(t)
1416
t.Parallel()
1517

1618
billing := getTestBillingAccountFromEnv(t)

google-beta/resource_google_project_service_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
// Test that services can be enabled and disabled on a project
1414
func TestAccProjectService_basic(t *testing.T) {
1515
t.Parallel()
16+
// Multiple fine-grained resources
17+
skipIfVcr(t)
1618

1719
org := getTestOrgFromEnv(t)
1820
pid := fmt.Sprintf("tf-test-%d", randInt(t))

google-beta/resource_runtimeconfig_variable_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ func TestAccRuntimeconfigVariable_basicValue(t *testing.T) {
108108
}
109109

110110
func TestAccRuntimeconfigVariable_errorsOnBothValueAndText(t *testing.T) {
111+
// Unit test, no HTTP interactions
112+
skipIfVcr(t)
111113
t.Parallel()
112114

113115
vcrTest(t, resource.TestCase{

google-beta/resource_storage_bucket_iam_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
func TestAccStorageBucketIamPolicy(t *testing.T) {
1111
t.Parallel()
1212

13+
serviceAcct := getTestServiceAccountFromEnv(t)
1314
bucket := fmt.Sprintf("tf-test-%d", randInt(t))
1415
account := fmt.Sprintf("tf-test-%d", randInt(t))
15-
serviceAcct := getTestServiceAccountFromEnv(t)
1616

1717
vcrTest(t, resource.TestCase{
1818
PreCheck: func() { testAccPreCheck(t) },

0 commit comments

Comments
 (0)