@@ -10,6 +10,7 @@ import (
1010 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1111 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1212 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
13+ "github.com/stretchr/testify/require"
1314
1415 "github.com/grafana/terraform-provider-grafana/v3/internal/testutils"
1516)
@@ -483,6 +484,53 @@ func TestAccContactPoint_inOrg(t *testing.T) {
483484 })
484485}
485486
487+ func TestAccContactPoint_recreate (t * testing.T ) {
488+ testutils .CheckOSSTestsEnabled (t , ">=9.1.0" )
489+
490+ var points models.ContactPoints
491+ name := acctest .RandString (10 )
492+ config := testutils .TestAccExampleWithReplace (t , "resources/grafana_contact_point/resource.tf" , map [string ]string {
493+ "My Contact Point" : name ,
494+ })
495+
496+ resource .ParallelTest (t , resource.TestCase {
497+ ProtoV5ProviderFactories : testutils .ProtoV5ProviderFactories ,
498+ Steps : []resource.TestStep {
499+ // Creation
500+ {
501+ Config : config ,
502+ Check : resource .ComposeTestCheckFunc (
503+ checkAlertingContactPointExistsWithLength ("grafana_contact_point.my_contact_point" , & points , 1 ),
504+ resource .TestCheckResourceAttr ("grafana_contact_point.my_contact_point" , "name" , name ),
505+ resource .TestCheckResourceAttr ("grafana_contact_point.my_contact_point" , "email.#" , "1" ),
506+ ),
507+ },
508+ // Delete the contact point and check that it is missing
509+ {
510+ PreConfig : func () {
511+ client := grafanaTestClient ()
512+ for _ , point := range points {
513+ _ , err := client .Provisioning .DeleteContactpoints (point .UID )
514+ require .NoError (t , err )
515+ }
516+ },
517+ Config : config ,
518+ PlanOnly : true ,
519+ ExpectNonEmptyPlan : true ,
520+ },
521+ // Recreate the contact point
522+ {
523+ Config : config ,
524+ Check : resource .ComposeTestCheckFunc (
525+ checkAlertingContactPointExistsWithLength ("grafana_contact_point.my_contact_point" , & points , 1 ),
526+ resource .TestCheckResourceAttr ("grafana_contact_point.my_contact_point" , "name" , name ),
527+ resource .TestCheckResourceAttr ("grafana_contact_point.my_contact_point" , "email.#" , "1" ),
528+ ),
529+ },
530+ },
531+ })
532+ }
533+
486534func TestAccContactPoint_empty (t * testing.T ) {
487535 testutils .CheckOSSTestsEnabled (t , ">=9.1.0" )
488536
0 commit comments