Skip to content

Commit

Permalink
Merge pull request #7 from imjaroiswebdev/suggestion-to-alenapan-even…
Browse files Browse the repository at this point in the history
…t-orchestration-dynamic-routing-and-esc-policy-support

add acc test `EventOrchestrationPathRouterDynamicRouteTo_import`
  • Loading branch information
c-kaieong authored Jul 19, 2024
2 parents 063be85 + b77f55b commit c89083a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pagerduty/import_pagerduty_event_orchestration_path_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/heimweh/go-pagerduty/pagerduty"
)

func TestAccPagerDutyEventOrchestrationPathRouter_import(t *testing.T) {
Expand Down Expand Up @@ -37,6 +38,39 @@ func TestAccPagerDutyEventOrchestrationPathRouter_import(t *testing.T) {
})
}

func TestAccPagerDutyEventOrchestrationPathRouterDynamicRouteTo_import(t *testing.T) {
team := fmt.Sprintf("tf-name-%s", acctest.RandString(5))
escalationPolicy := fmt.Sprintf("tf-%s", acctest.RandString(5))
service := fmt.Sprintf("tf-%s", acctest.RandString(5))
orchestration := fmt.Sprintf("tf-orchestration-%s", acctest.RandString(5))
dynamicRouteToByNameInput := &pagerduty.EventOrchestrationPathDynamicRouteTo{
LookupBy: "service_name",
Regex: ".*",
Source: "event.custom_details.pd_service_name",
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPagerDutyEventOrchestrationRouterDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyEventOrchestrationRouterDynamicRouteToConfig(team, escalationPolicy, service, orchestration, dynamicRouteToByNameInput),
},
{
ResourceName: "pagerduty_event_orchestration_router.router",
ImportStateIdFunc: testAccCheckPagerDutyEventOrchestrationPathRouterID,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"set.0.rule.0.id",
"set.0.rule.1.id",
},
},
},
})
}

func testAccCheckPagerDutyEventOrchestrationPathRouterID(s *terraform.State) (string, error) {
return s.RootModule().Resources["pagerduty_event_orchestration.orch"].Primary.ID, nil
}

0 comments on commit c89083a

Please sign in to comment.