Skip to content

Commit

Permalink
fix: issue-10386 (GoogleCloudPlatform#5461)
Browse files Browse the repository at this point in the history
  • Loading branch information
c4po authored and betsy-lichtenberg committed Apr 25, 2022
1 parent b7a90a9 commit c139ff4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions mmv1/products/essentialcontacts/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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", "[email protected]"),
),
},
{
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", "[email protected]"),
),
},
{
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 = "[email protected]"
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 = "[email protected]"
language_tag = "en-GB"
notification_category_subscriptions = ["ALL"]
}
`, context)
}

0 comments on commit c139ff4

Please sign in to comment.