Merge pull request #12434 from hashicorp/paddy_fix_gcp_storage_region_test

provider/google: add location to storage tests.
This commit is contained in:
Paddy 2017-03-03 16:58:18 -08:00 committed by GitHub
commit 6de8e25b16
1 changed files with 13 additions and 6 deletions

View File

@ -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)
}