|
| 1 | +package apphub_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 7 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 8 | +) |
| 9 | + |
| 10 | +func TestDataSourceApphubApplication_basic(t *testing.T) { |
| 11 | + t.Parallel() |
| 12 | + |
| 13 | + context := map[string]interface{}{ |
| 14 | + "random_suffix": acctest.RandString(t, 10), |
| 15 | + } |
| 16 | + |
| 17 | + acctest.VcrTest(t, resource.TestCase{ |
| 18 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 19 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 20 | + CheckDestroy: testAccCheckApphubApplicationDestroyProducer(t), |
| 21 | + Steps: []resource.TestStep{ |
| 22 | + { |
| 23 | + Config: testDataSourceApphubApplication_basic(context), |
| 24 | + Check: resource.ComposeTestCheckFunc( |
| 25 | + acctest.CheckDataSourceStateMatchesResourceState("data.google_apphub_application.example_data", "google_apphub_application.example"), |
| 26 | + ), |
| 27 | + }, |
| 28 | + }, |
| 29 | + }) |
| 30 | +} |
| 31 | + |
| 32 | +func testDataSourceApphubApplication_basic(context map[string]interface{}) string { |
| 33 | + return acctest.Nprintf(` |
| 34 | +
|
| 35 | +data "google_apphub_application" "example_data" { |
| 36 | + project = google_apphub_application.example.project |
| 37 | + application_id = google_apphub_application.example.application_id |
| 38 | + location = google_apphub_application.example.location |
| 39 | +} |
| 40 | +
|
| 41 | +resource "google_apphub_application" "example" { |
| 42 | + location = "us-central1" |
| 43 | + application_id = "tf-test-example-application%{random_suffix}" |
| 44 | + display_name = "Application Full New%{random_suffix}" |
| 45 | + scope { |
| 46 | + type = "REGIONAL" |
| 47 | + } |
| 48 | + attributes { |
| 49 | + environment { |
| 50 | + type = "STAGING" |
| 51 | + } |
| 52 | + criticality { |
| 53 | + type = "MISSION_CRITICAL" |
| 54 | + } |
| 55 | + business_owners { |
| 56 | + display_name = "Alice%{random_suffix}" |
| 57 | + email = "[email protected]%{random_suffix}" |
| 58 | + } |
| 59 | + developer_owners { |
| 60 | + display_name = "Bob%{random_suffix}" |
| 61 | + email = "[email protected]%{random_suffix}" |
| 62 | + } |
| 63 | + operator_owners { |
| 64 | + display_name = "Charlie%{random_suffix}" |
| 65 | + email = "[email protected]%{random_suffix}" |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +`, context) |
| 70 | +} |
0 commit comments