@@ -430,7 +430,6 @@ func datadogTestCase(t *testing.T) *resource.TestCase {
430430 },
431431 }
432432}
433-
434433func TestAccConfigRSAlertConfiguration_withPagerDuty (t * testing.T ) {
435434 proxyPort := replay .SetupReplayProxy (t )
436435
@@ -464,6 +463,46 @@ func TestAccConfigRSAlertConfiguration_withPagerDuty(t *testing.T) {
464463 })
465464}
466465
466+ func TestAccConfigRSAlertConfiguration_withEmailToPagerDuty (t * testing.T ) {
467+ proxyPort := replay .SetupReplayProxy (t )
468+
469+ var (
470+ projectID = replay .ManageProjectID (t , acc .ProjectIDExecution )
471+ serviceKey = dummy32CharKey
472+ )
473+
474+ resource .ParallelTest (t , resource.TestCase {
475+ PreCheck : func () { acc .PreCheckBasic (t ) },
476+ ProtoV6ProviderFactories : acc .TestAccProviderV6FactoriesWithProxy (proxyPort ),
477+ CheckDestroy : checkDestroyUsingProxy (proxyPort ),
478+ Steps : []resource.TestStep {
479+ {
480+ Config : configWithEmail (projectID , true ),
481+ Check : resource .ComposeAggregateTestCheckFunc (
482+ checkExistsUsingProxy (proxyPort , resourceName ),
483+ resource .TestCheckResourceAttr (resourceName , "project_id" , projectID ),
484+ ),
485+ },
486+ {
487+ Config : configWithPagerDuty (projectID , serviceKey , true ),
488+ Check : resource .ComposeAggregateTestCheckFunc (
489+ checkExistsUsingProxy (proxyPort , resourceName ),
490+ resource .TestCheckResourceAttr (resourceName , "project_id" , projectID ),
491+ ),
492+ },
493+ {
494+ ResourceName : resourceName ,
495+ ImportStateIdFunc : importStateProjectIDFunc (resourceName ),
496+ ImportState : true ,
497+ ImportStateVerify : true ,
498+ // service key is not returned by api in import operation
499+ // integration_id is not returned during Create
500+ ImportStateVerifyIgnore : []string {"updated" , "notification.0.service_key" , "notification.0.integration_id" },
501+ },
502+ },
503+ })
504+ }
505+
467506func TestAccConfigAlertConfiguration_PagerDutyUsingIntegrationID (t * testing.T ) {
468507 // create a new project as it need to ensure no third party integration has already been created
469508 var (
@@ -848,6 +887,22 @@ func configWithPagerDuty(projectID, serviceKey string, enabled bool) string {
848887 ` , projectID , serviceKey , enabled )
849888}
850889
890+ func configWithEmail (projectID string , enabled bool ) string {
891+ return fmt .Sprintf (`
892+ resource "mongodbatlas_alert_configuration" "test" {
893+ project_id = %[1]q
894+ enabled = %[2]t
895+ event_type = "NO_PRIMARY"
896+
897+ notification {
898+ type_name = "EMAIL"
899+ interval_min = 60
900+ email_address = "test@mongodbtest.com"
901+ }
902+ }
903+ ` , projectID , enabled )
904+ }
905+
851906func configWithPagerDutyIntegrationID (orgID , projectName , serviceKey string ) string {
852907 return fmt .Sprintf (`
853908 resource "mongodbatlas_project" "test" {
0 commit comments