Skip to content

Commit

Permalink
Add an additional test with multiple project metadata items (#222)
Browse files Browse the repository at this point in the history
This additional test would have caught the error fixed in
8f75c1c
  • Loading branch information
selmanj authored Jul 28, 2017
1 parent 88b1f09 commit 060861e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions google/resource_compute_project_metadata_item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

0 comments on commit 060861e

Please sign in to comment.