Skip to content

Commit

Permalink
fix TestAccAppEngineApplication* tests (#8486) (#15344)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jul 31, 2023
1 parent 27cbcf6 commit 99beb1e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .changelog/8486.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
24 changes: 15 additions & 9 deletions google/resource_app_engine_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,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 @@ -36,7 +38,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 @@ -52,13 +54,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 @@ -70,12 +73,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 @@ -90,15 +94,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 @@ -108,15 +113,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 @@ -126,5 +132,5 @@ resource "google_app_engine_application" "acceptance" {
database_type = "CLOUD_DATASTORE_COMPATIBILITY"
serving_status = "USER_DISABLED"
}
`, pid, pid, org)
`, pid, pid, org, billingAccount)
}
6 changes: 4 additions & 2 deletions google/resource_app_engine_firewall_rule_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ func TestAccAppEngineFirewallRule_appEngineFirewallRuleBasicExample(t *testing.T
t.Parallel()

context := map[string]interface{}{
"org_id": envvar.GetTestOrgFromEnv(t),
"random_suffix": acctest.RandString(t, 10),
"org_id": envvar.GetTestOrgFromEnv(t),
"billing_account": envvar.GetTestBillingAccountFromEnv(t),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
Expand All @@ -62,6 +63,7 @@ resource "google_project" "my_project" {
name = "tf-test-project"
project_id = "tf-test-ae-project%{random_suffix}"
org_id = "%{org_id}"
billing_account = "%{billing_account}"
}
resource "google_app_engine_application" "app" {
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/app_engine_firewall_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ resource "google_project" "my_project" {
name = "tf-test-project"
project_id = "ae-project"
org_id = "123456789"
billing_account = "000000-0000000-0000000-000000"
}
resource "google_app_engine_application" "app" {
Expand Down

0 comments on commit 99beb1e

Please sign in to comment.