Skip to content

Commit

Permalink
actually fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danawillow authored and modular-magician committed Dec 20, 2019
1 parent 10a85c4 commit 3e56fa7
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions third_party/terraform/tests/resource_kms_crypto_key_iam_test.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func TestAccKmsCryptoKeyIamPolicy(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccKmsCryptoKeyIamPolicy_basic(projectId, orgId, billingAccount, account, keyRingName, cryptoKeyName, roleId),
Check: testAccCheckGoogleCryptoKmsKeyIam(roleId, []string{
Check: testAccCheckGoogleCryptoKmsKeyIam("foo", roleId, []string{
fmt.Sprintf("serviceAccount:%s@%s.iam.gserviceaccount.com", account, projectId),
}),
},
Expand Down Expand Up @@ -234,9 +234,6 @@ func TestAccKmsCryptoKeyIamPolicy_withCondition(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccKmsCryptoKeyIamPolicy_withCondition(projectId, orgId, billingAccount, account, keyRingName, cryptoKeyName, roleId, conditionTitle),
Check: testAccCheckGoogleCryptoKmsKeyIam(roleId, []string{
fmt.Sprintf("serviceAccount:%s@%s.iam.gserviceaccount.com", account, projectId),
}),
},
{
ResourceName: "google_kms_crypto_key_iam_policy.foo",
Expand Down Expand Up @@ -320,9 +317,9 @@ func testAccCheckGoogleKmsCryptoKeyIamMemberExists(n, role, member string) resou
}
}

func testAccCheckGoogleCryptoKmsKeyIam(role string, members []string) resource.TestCheckFunc {
func testAccCheckGoogleCryptoKmsKeyIam(n, role string, members []string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources["google_kms_crypto_key_iam_policy"]
rs, ok := s.RootModule().Resources["google_kms_crypto_key_iam_policy."+n]
if !ok {
return fmt.Errorf("IAM policy resource not found")
}
Expand Down Expand Up @@ -623,14 +620,14 @@ resource "google_project_service" "iam" {
}

resource "google_service_account" "test_account" {
project = google_project_services.test_project.project
project = google_project_service.iam.project
account_id = "%s"
display_name = "Kms Key Ring Iam Testing Account"
display_name = "Kms Crypto Key Iam Testing Account"
}

resource "google_kms_key_ring" "key_ring" {
project = google_project_services.test_project.project
location = "%s"
project = google_project_service.iam.project
location = "us-central1"
name = "%s"
}

Expand All @@ -650,7 +647,7 @@ resource "google_kms_crypto_key_iam_policy" "foo" {
crypto_key_id = google_kms_crypto_key.crypto_key.id
policy_data = data.google_iam_policy.foo.policy_data
}
`, projectId, orgId, billingAccount, account, DEFAULT_KMS_TEST_LOCATION, keyRingName, cryptoKeyName, roleId)
`, projectId, orgId, billingAccount, account, keyRingName, cryptoKeyName, roleId)
}

<% unless version == 'ga' -%>
Expand All @@ -674,14 +671,14 @@ resource "google_project_service" "iam" {
}

resource "google_service_account" "test_account" {
project = google_project_services.test_project.project
project = google_project_service.iam.project
account_id = "%s"
display_name = "Kms Key Ring Iam Testing Account"
display_name = "Kms Crypto Key Iam Testing Account"
}

resource "google_kms_key_ring" "key_ring" {
project = google_project_services.test_project.project
location = "%s"
project = google_project_service.iam.project
location = "us-central1"
name = "%s"
}

Expand All @@ -706,6 +703,6 @@ resource "google_kms_crypto_key_iam_policy" "foo" {
crypto_key_id = google_kms_crypto_key.crypto_key.id
policy_data = data.google_iam_policy.foo.policy_data
}
`, projectId, orgId, billingAccount, account, DEFAULT_KMS_TEST_LOCATION, keyRingName, cryptoKeyName, roleId, conditionTitle)
`, projectId, orgId, billingAccount, account, keyRingName, cryptoKeyName, roleId, conditionTitle)
}
<% end -%>

0 comments on commit 3e56fa7

Please sign in to comment.