Skip to content

Commit

Permalink
VCR acc test fixes (#3586) (#6507)
Browse files Browse the repository at this point in the history
* 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 <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jun 2, 2020
1 parent ef4ce85 commit a8af524
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/3586.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
4 changes: 3 additions & 1 deletion google/iam_storage_bucket_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ func TestAccStorageBucketIamMemberGenerated(t *testing.T) {
func TestAccStorageBucketIamPolicyGenerated(t *testing.T) {
t.Parallel()

// This may skip test, so do it first
sa := getTestServiceAccountFromEnv(t)
context := map[string]interface{}{
"random_suffix": randString(t, 10),
"role": "roles/storage.objectViewer",
"admin_role": "roles/storage.admin",
}
context["service_account"] = getTestServiceAccountFromEnv(t)
context["service_account"] = sa

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
2 changes: 1 addition & 1 deletion google/resource_bigquery_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestAccBigQueryTable_HivePartitioning(t *testing.T) {
datasetID := fmt.Sprintf("tf_test_%s", randString(t, 10))
tableID := fmt.Sprintf("tf_test_%s", randString(t, 10))

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigQueryTableDestroyProducer(t),
Expand Down
1 change: 1 addition & 0 deletions google/resource_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3076,6 +3076,7 @@ func testAccComputeInstance_disks_kms(pid string, bootEncryptionKey string, disk
for k := range diskNameToEncryptionKey {
diskNames = append(diskNames, k)
}
sort.Strings(diskNames)
return fmt.Sprintf(`
data "google_project" "project" {
project_id = "%s"
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_project_metadata_item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func TestAccComputeProjectMetadataItem_basic(t *testing.T) {
}

func TestAccComputeProjectMetadataItem_basicMultiple(t *testing.T) {
// Multiple fine grained items applied in same config
skipIfVcr(t)
t.Parallel()

// Generate a config of two config keys
Expand Down
2 changes: 2 additions & 0 deletions google/resource_dataproc_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ func TestAccDataprocCluster_withLabels(t *testing.T) {
}

func TestAccDataprocCluster_withNetworkRefs(t *testing.T) {
// Multiple fine-grained resources
skipIfVcr(t)
t.Parallel()

var c1, c2 dataproc.Cluster
Expand Down
2 changes: 2 additions & 0 deletions google/resource_google_billing_account_iam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestAccBillingAccountIam(t *testing.T) {
// Deletes two fine-grained resources in same step
skipIfVcr(t)
t.Parallel()

billing := getTestBillingAccountFromEnv(t)
Expand Down
2 changes: 2 additions & 0 deletions google/resource_google_project_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
// Test that services can be enabled and disabled on a project
func TestAccProjectService_basic(t *testing.T) {
t.Parallel()
// Multiple fine-grained resources
skipIfVcr(t)

org := getTestOrgFromEnv(t)
pid := fmt.Sprintf("tf-test-%d", randInt(t))
Expand Down
2 changes: 2 additions & 0 deletions google/resource_runtimeconfig_variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func TestAccRuntimeconfigVariable_basicValue(t *testing.T) {
}

func TestAccRuntimeconfigVariable_errorsOnBothValueAndText(t *testing.T) {
// Unit test, no HTTP interactions
skipIfVcr(t)
t.Parallel()

vcrTest(t, resource.TestCase{
Expand Down
2 changes: 1 addition & 1 deletion google/resource_storage_bucket_iam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
func TestAccStorageBucketIamPolicy(t *testing.T) {
t.Parallel()

serviceAcct := getTestServiceAccountFromEnv(t)
bucket := fmt.Sprintf("tf-test-%d", randInt(t))
account := fmt.Sprintf("tf-test-%d", randInt(t))
serviceAcct := getTestServiceAccountFromEnv(t)

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down

0 comments on commit a8af524

Please sign in to comment.