Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix TestAccAppEngineApplication* tests #8486

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mmv1/products/appengine/FirewallRule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ examples:
project_id: 'ae-project'
test_env_vars:
org_id: :ORG_ID
billing_account: :BILLING_ACCT
parameters:
- !ruby/object:Api::Type::Integer
name: 'priority'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ resource "google_project" "my_project" {
name = "tf-test-project"
project_id = "<%= ctx[:vars]['project_id'] %>"
org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>"
}

resource "google_app_engine_application" "app" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ func TestAccAppEngineApplication_basic(t *testing.T) {

org := envvar.GetTestOrgFromEnv(t)
pid := fmt.Sprintf("tf-test-%d", acctest.RandInt(t))
billingAccount := envvar.GetTestBillingAccountFromEnv(t)

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccAppEngineApplication_basic(pid, org),
Config: testAccAppEngineApplication_basic(pid, org, billingAccount),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("google_app_engine_application.acceptance", "url_dispatch_rule.#"),
resource.TestCheckResourceAttrSet("google_app_engine_application.acceptance", "name"),
Expand All @@ -34,7 +36,7 @@ func TestAccAppEngineApplication_basic(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccAppEngineApplication_update(pid, org),
Config: testAccAppEngineApplication_update(pid, org, billingAccount),
},
{
ResourceName: "google_app_engine_application.acceptance",
Expand All @@ -50,13 +52,14 @@ func TestAccAppEngineApplication_withIAP(t *testing.T) {

org := envvar.GetTestOrgFromEnv(t)
pid := fmt.Sprintf("tf-test-%d", acctest.RandInt(t))
billingAccount := envvar.GetTestBillingAccountFromEnv(t)

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccAppEngineApplication_withIAP(pid, org),
Config: testAccAppEngineApplication_withIAP(pid, org, billingAccount),
},
{
ResourceName: "google_app_engine_application.acceptance",
Expand All @@ -68,12 +71,13 @@ func TestAccAppEngineApplication_withIAP(t *testing.T) {
})
}

func testAccAppEngineApplication_withIAP(pid, org string) string {
func testAccAppEngineApplication_withIAP(pid, org, billingAccount string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
name = "%s"
org_id = "%s"
billing_account = "%s"
}

resource "google_app_engine_application" "acceptance" {
Expand All @@ -88,15 +92,16 @@ resource "google_app_engine_application" "acceptance" {
oauth2_client_secret = "test"
}
}
`, pid, pid, org)
`, pid, pid, org, billingAccount)
}

func testAccAppEngineApplication_basic(pid, org string) string {
func testAccAppEngineApplication_basic(pid, org, billingAccount string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
name = "%s"
org_id = "%s"
billing_account = "%s"
}

resource "google_app_engine_application" "acceptance" {
Expand All @@ -106,15 +111,16 @@ resource "google_app_engine_application" "acceptance" {
database_type = "CLOUD_DATASTORE_COMPATIBILITY"
serving_status = "SERVING"
}
`, pid, pid, org)
`, pid, pid, org, billingAccount)
}

func testAccAppEngineApplication_update(pid, org string) string {
func testAccAppEngineApplication_update(pid, org, billingAccount string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
name = "%s"
org_id = "%s"
billing_account = "%s"
}

resource "google_app_engine_application" "acceptance" {
Expand All @@ -124,5 +130,5 @@ resource "google_app_engine_application" "acceptance" {
database_type = "CLOUD_DATASTORE_COMPATIBILITY"
serving_status = "USER_DISABLED"
}
`, pid, pid, org)
`, pid, pid, org, billingAccount)
}