Skip to content

Commit

Permalink
Add update displayName test
Browse files Browse the repository at this point in the history
  • Loading branch information
rainshen49 committed Feb 7, 2024
1 parent 0c75e2d commit c38232e
Showing 1 changed file with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package firebaseappcheck_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
)

func TestAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenUpdate(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"project_id": envvar.GetTestProjectFromEnv(),
"display_name": "Debug Token 1",
"token": "5E728315-E121-467F-BCA1-1FE71130BB98",
}

contextUpdated := map[string]interface{}{
"project_id": envvar.GetTestProjectFromEnv(),
"display_name": "Debug Token 2",
"token": "5E728315-E121-467F-BCA1-1FE71130BB98",
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"random": {},
"time": {},
},
CheckDestroy: testAccCheckFirebaseAppCheckDebugTokenDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenTemplate(context),
},
{
ResourceName: "google_firebase_app_check_debug_token.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"debug_token_id", "token", "app_id"},
},
{
Config: testAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenTemplate(contextUpdated),
},
{
ResourceName: "google_firebase_app_check_debug_token.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"debug_token_id", "token", "app_id"},
},
},
})
}

func testAccFirebaseAppCheckDebugToken_firebaseAppCheckDebugTokenTemplate(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_firebase_web_app" "default" {
project = "%{project_id}"
display_name = "Web App for debug token"
}
# It takes a while for App Check to recognize the new app
# If your app already exists, you don't have to wait 30 seconds.
resource "time_sleep" "wait_30s" {
depends_on = [google_firebase_web_app.default]
create_duration = "30s"
}
resource "google_firebase_app_check_debug_token" "default" {
project = "%{project_id}"
app_id = google_firebase_web_app.default.app_id
display_name = "%{display_name}"
token = "%{token}"
depends_on = [time_sleep.wait_30s]
}
`, context)
}

0 comments on commit c38232e

Please sign in to comment.