mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-06 02:31:05 +00:00
3d1e11023d
* Make google_service_account resource importable * Add google_service_account testcase with default project * Mark google_service_account.project as computed to ensure the project id is always stored in the state, defined in configuration or not. Add corresponding test cases * Inline variables with single usage * Replace tabs with spaces in configuration strings * Ensure service account is not recreated when the default project is explicitely added to the configuration * camelcase
69 lines
1.6 KiB
Go
69 lines
1.6 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"os"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestAccGoogleServiceAccount_importBasic(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccGoogleServiceAccount_import("terraform-" + acctest.RandString(10)),
|
|
},
|
|
|
|
resource.TestStep{
|
|
ResourceName: "google_service_account.acceptance",
|
|
ImportState: true,
|
|
ImportStateVerify: true,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccGoogleServiceAccount_import(saName string) string {
|
|
return fmt.Sprintf(`
|
|
resource "google_service_account" "acceptance" {
|
|
account_id = "%s"
|
|
display_name = "%s"
|
|
}`, saName, saName)
|
|
}
|
|
|
|
func TestAccGoogleServiceAccount_importWithProject(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccGoogleServiceAccount_importWithProject(os.Getenv("GOOGLE_PROJECT"), "terraform-"+acctest.RandString(10)),
|
|
},
|
|
|
|
resource.TestStep{
|
|
ResourceName: "google_service_account.acceptance",
|
|
ImportState: true,
|
|
ImportStateVerify: true,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccGoogleServiceAccount_importWithProject(project, saName string) string {
|
|
return fmt.Sprintf(`
|
|
resource "google_service_account" "acceptance" {
|
|
project = "%s"
|
|
account_id = "%s"
|
|
display_name = "%s"
|
|
}`, project, saName, saName)
|
|
}
|