From ff21000bed530beeb20b1767e3ffe13edea6c6f3 Mon Sep 17 00:00:00 2001 From: Max Cai Date: Wed, 17 Nov 2021 12:02:02 -0500 Subject: [PATCH] fix: issue-10386 --- mmv1/products/essentialcontacts/api.yaml | 1 + ...esource_essential_contacts_contact_test.go | 77 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 mmv1/third_party/terraform/tests/resource_essential_contacts_contact_test.go diff --git a/mmv1/products/essentialcontacts/api.yaml b/mmv1/products/essentialcontacts/api.yaml index 755fc040e933..e8be6253d41f 100644 --- a/mmv1/products/essentialcontacts/api.yaml +++ b/mmv1/products/essentialcontacts/api.yaml @@ -55,6 +55,7 @@ objects: The identifier for the contact. Format: {resourceType}/{resource_id}/contacts/{contact_id} - !ruby/object:Api::Type::String name: 'email' + input: true required: true description: | The email address to send notifications to. This does not need to be a Google account. diff --git a/mmv1/third_party/terraform/tests/resource_essential_contacts_contact_test.go b/mmv1/third_party/terraform/tests/resource_essential_contacts_contact_test.go new file mode 100644 index 000000000000..95f53ff44053 --- /dev/null +++ b/mmv1/third_party/terraform/tests/resource_essential_contacts_contact_test.go @@ -0,0 +1,77 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccEssentialContactsContact_update(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckEssentialContactsContactDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccEssentialContactsContact_v1(context), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_essential_contacts_contact.contact", + "email", "foo_v1@bar.com"), + ), + }, + { + ResourceName: "google_essential_contacts_contact.contact", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"parent"}, + }, + { + Config: testAccEssentialContactsContact_v2(context), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_essential_contacts_contact.contact", + "email", "foo_v2@bar.com"), + ), + }, + { + ResourceName: "google_essential_contacts_contact.contact", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"parent"}, + }, + }, + }) +} + +func testAccEssentialContactsContact_v1(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "project" { +} + +resource "google_essential_contacts_contact" "contact" { + parent = data.google_project.project.id + email = "foo_v1@bar.com" + language_tag = "en-GB" + notification_category_subscriptions = ["ALL"] +} +`, context) +} + +func testAccEssentialContactsContact_v2(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "project" { +} + +resource "google_essential_contacts_contact" "contact" { + parent = data.google_project.project.id + email = "foo_v2@bar.com" + language_tag = "en-GB" + notification_category_subscriptions = ["ALL"] +} +`, context) +}