Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 10386 #10541

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions google/resource_essential_contacts_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func resourceEssentialContactsContact() *schema.Resource {
"email": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `The email address to send notifications to. This does not need to be a Google account.`,
},
"language_tag": {
Expand Down
77 changes: 77 additions & 0 deletions google/resource_essential_contacts_contact_test.go
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)
}