Merge pull request #12434 from hashicorp/paddy_fix_gcp_storage_region_test
provider/google: add location to storage tests.
This commit is contained in:
commit
6de8e25b16
|
@ -68,7 +68,7 @@ func TestAccStorageStorageClass(t *testing.T) {
|
||||||
CheckDestroy: testAccGoogleStorageDestroy,
|
CheckDestroy: testAccGoogleStorageDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "MULTI_REGIONAL"),
|
Config: testGoogleStorageBucketsReaderStorageClass(bucketName, "MULTI_REGIONAL", ""),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCloudStorageBucketExists(
|
testAccCheckCloudStorageBucketExists(
|
||||||
"google_storage_bucket.bucket", bucketName),
|
"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(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCloudStorageBucketExists(
|
testAccCheckCloudStorageBucketExists(
|
||||||
"google_storage_bucket.bucket", bucketName),
|
"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(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCloudStorageBucketExists(
|
testAccCheckCloudStorageBucketExists(
|
||||||
"google_storage_bucket.bucket", bucketName),
|
"google_storage_bucket.bucket", bucketName),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"google_storage_bucket.bucket", "storage_class", "REGIONAL"),
|
"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)
|
`, 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(`
|
return fmt.Sprintf(`
|
||||||
resource "google_storage_bucket" "bucket" {
|
resource "google_storage_bucket" "bucket" {
|
||||||
name = "%s"
|
name = "%s"
|
||||||
storage_class = "%s"
|
storage_class = "%s"%s
|
||||||
}
|
}
|
||||||
`, bucketName, storageClass)
|
`, bucketName, storageClass, locationBlock)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue