From 629dfe7ad78ba9d54671f15b6fe330a0fad34726 Mon Sep 17 00:00:00 2001 From: Paddy Date: Fri, 3 Mar 2017 15:51:36 -0800 Subject: [PATCH] provider/google: add location to storage tests. Add location to storage tests that need it, which fixes the failing TestAccStorageStorageClass test. --- resource_storage_bucket_test.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/resource_storage_bucket_test.go b/resource_storage_bucket_test.go index 59591639..417164be 100644 --- a/resource_storage_bucket_test.go +++ b/resource_storage_bucket_test.go @@ -68,7 +68,7 @@ func TestAccStorageStorageClass(t *testing.T) { CheckDestroy: testAccGoogleStorageDestroy, Steps: []resource.TestStep{ { - Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "MULTI_REGIONAL"), + Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "MULTI_REGIONAL", ""), Check: resource.ComposeTestCheckFunc( testAccCheckCloudStorageBucketExists( "google_storage_bucket.bucket", bucketName), @@ -77,7 +77,7 @@ func TestAccStorageStorageClass(t *testing.T) { ), }, { - Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "NEARLINE"), + Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "NEARLINE", ""), Check: resource.ComposeTestCheckFunc( testAccCheckCloudStorageBucketExists( "google_storage_bucket.bucket", bucketName), @@ -86,12 +86,14 @@ func TestAccStorageStorageClass(t *testing.T) { ), }, { - Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "REGIONAL"), + Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "REGIONAL", "us-central1"), Check: resource.ComposeTestCheckFunc( testAccCheckCloudStorageBucketExists( "google_storage_bucket.bucket", bucketName), resource.TestCheckResourceAttr( "google_storage_bucket.bucket", "storage_class", "REGIONAL"), + resource.TestCheckResourceAttr( + "google_storage_bucket.bucket", "location", "us-central1"), ), }, }, @@ -266,11 +268,16 @@ resource "google_storage_bucket" "bucket" { `, bucketName) } -func testGoogleStorageBucketsReaderStorageClass(bucketName string, storageClass string) string { +func testGoogleStorageBucketsReaderStorageClass(bucketName, storageClass, location string) string { + var locationBlock string + if location != "" { + locationBlock = fmt.Sprintf(` + location = "%s"`, location) + } return fmt.Sprintf(` resource "google_storage_bucket" "bucket" { name = "%s" - storage_class = "%s" + storage_class = "%s"%s } -`, bucketName, storageClass) +`, bucketName, storageClass, locationBlock) }