Add an additional test with multiple project metadata items (#222)

This additional test would have caught the error fixed in
8f75c1c9a5
This commit is contained in:
Joe Selman 2017-07-28 15:50:12 -07:00 committed by GitHub
parent 88b1f092ff
commit 060861e678

View File

@ -28,6 +28,26 @@ func TestAccComputeProjectMetadataItem_basic(t *testing.T) {
})
}
func TestAccComputeProjectMetadataItem_basicMultiple(t *testing.T) {
// Generate a config of two config keys
config := testAccProjectMetadataItem_basic("myKey", "myValue") +
testAccProjectMetadataItem_basic("myOtherKey", "myOtherValue")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckProjectMetadataItemDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckProjectMetadataItem_hasMetadata("myKey", "myValue"),
testAccCheckProjectMetadataItem_hasMetadata("myOtherKey", "myOtherValue"),
),
},
},
})
}
func TestAccComputeProjectMetadataItem_basicWithEmptyVal(t *testing.T) {
// Key must be unique to avoid concurrent tests interfering with each other
key := "myKey" + acctest.RandString(10)
@ -120,9 +140,9 @@ func testAccCheckProjectMetadataItemDestroy(s *terraform.State) error {
func testAccProjectMetadataItem_basic(key, val string) string {
return fmt.Sprintf(`
resource "google_compute_project_metadata_item" "foobar" {
resource "google_compute_project_metadata_item" "foobar-%s" {
key = "%s"
value = "%s"
}
`, key, val)
`, acctest.RandString(10), key, val)
}