-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change allowed recipients to optional
- Loading branch information
1 parent
cec02b4
commit 2e2387b
Showing
2 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,18 @@ func TestAcc_EmailNotificationIntegration(t *testing.T) { | |
} | ||
|
||
emailIntegrationName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) | ||
verifiedEmail := "[email protected]" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
Providers: acc.TestAccProviders(), | ||
PreCheck: func() { acc.TestAccPreCheck(t) }, | ||
CheckDestroy: nil, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: emailNotificationIntegrationConfig(emailIntegrationName), | ||
Config: emailNotificationIntegrationConfig(emailIntegrationName, verifiedEmail), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("snowflake_email_notification_integration.test", "name", emailIntegrationName), | ||
resource.TestCheckResourceAttr("snowflake_email_notification_integration.test", "allowed_recipients.0", verifiedEmail), | ||
), | ||
}, | ||
{ | ||
|
@@ -38,12 +41,12 @@ func TestAcc_EmailNotificationIntegration(t *testing.T) { | |
}) | ||
} | ||
|
||
func emailNotificationIntegrationConfig(name string) string { | ||
func emailNotificationIntegrationConfig(name string, email string) string { | ||
s := ` | ||
resource "snowflake_email_notification_integration" "test" { | ||
name = "%s" | ||
enabled = true | ||
allowed_recipients = ["[email protected]"] # Verified Email Addresses is required | ||
allowed_recipients = ["%s"] # Verified Email Addresses is required | ||
comment = "test" | ||
/* | ||
Error: error creating notification integration: 394209 (22023): | ||
|
@@ -52,5 +55,34 @@ Either these email addresses are not yet validated or do not belong to any user | |
*/ | ||
} | ||
` | ||
return fmt.Sprintf(s, name, email) | ||
} | ||
|
||
// TestAcc_EmailNotificationIntegration_issue2223 proves https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2223 issue. | ||
// Snowflake allowed empty allowed recipients in https://docs.snowflake.com/en/release-notes/2023/7_40#email-notification-integrations-allowed-recipients-no-longer-required. | ||
func TestAcc_EmailNotificationIntegration_issue2223(t *testing.T) { | ||
emailIntegrationName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) | ||
resource.Test(t, resource.TestCase{ | ||
Providers: acc.TestAccProviders(), | ||
PreCheck: func() { acc.TestAccPreCheck(t) }, | ||
CheckDestroy: nil, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: emailNotificationIntegrationWithoutRecipientsConfig(emailIntegrationName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("snowflake_email_notification_integration.test", "name", emailIntegrationName), | ||
resource.TestCheckNoResourceAttr("snowflake_email_notification_integration.test", "allowed_recipients"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func emailNotificationIntegrationWithoutRecipientsConfig(name string) string { | ||
s := ` | ||
resource "snowflake_email_notification_integration" "test" { | ||
name = "%s" | ||
enabled = true | ||
}` | ||
return fmt.Sprintf(s, name) | ||
} |