mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 09:36:44 +00:00
![Dana Hoffman](/assets/img/avatar_default.png)
I also did a bit of cleanup while I was here and noticed things that I thought could be improved in the files (wording changes, removing tests that aren't quite necessary, etc.) Take a look and make sure I didn't actually remove anything important!
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestAccDatasourceGoogleServiceAccount_basic(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resourceName := "data.google_service_account.acceptance"
|
|
account := acctest.RandomWithPrefix("tf-test")
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccCheckGoogleServiceAccount_basic(account),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr(
|
|
resourceName, "id", fmt.Sprintf("projects/%s/serviceAccounts/%s@%s.iam.gserviceaccount.com", getTestProjectFromEnv(), account, getTestProjectFromEnv())),
|
|
resource.TestCheckResourceAttrSet(resourceName, "email"),
|
|
resource.TestCheckResourceAttrSet(resourceName, "unique_id"),
|
|
resource.TestCheckResourceAttrSet(resourceName, "name"),
|
|
resource.TestCheckResourceAttrSet(resourceName, "display_name"),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccCheckGoogleServiceAccount_basic(account string) string {
|
|
return fmt.Sprintf(`
|
|
resource "google_service_account" "acceptance" {
|
|
account_id = "%s"
|
|
display_name = "Testing Account"
|
|
}
|
|
|
|
data "google_service_account" "acceptance" {
|
|
account_id = "${google_service_account.acceptance.account_id}"
|
|
}
|
|
`, account)
|
|
}
|