Skip to content

Commit

Permalink
Merge pull request PagerDuty#814 from imjaroiswebdev/issue-652-fail-e…
Browse files Browse the repository at this point in the history
…nabling-eo-routes

[CSGI-2574] Address: Fail to enable rules in pagerduty_event_orchestration_router
  • Loading branch information
imjaroiswebdev authored Feb 6, 2024
2 parents 7133e1f + 2e56eef commit 4d2a0b7
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/hashicorp/terraform-plugin-mux v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/hashicorp/terraform-plugin-testing v1.6.0
github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326 h1:ZyL8A1yPg0C9rUKc/QCUNM848NJ9DhTE/cRZH54y/5s=
github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76 h1:+JY7wpGAsTe/r51/nTdo3pQQ2Wj4cTXpsQfij1JK2gc=
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,41 @@ func TestAccPagerDutyEventOrchestrationPathRouter_Basic(t *testing.T) {
})
}

func TestAccPagerDutyEventOrchestrationPathRouter_EnableRoutingRule(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))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPagerDutyEventOrchestrationRouterDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfig(team, escalationPolicy, service, orchestration),
Check: resource.ComposeTestCheckFunc(
testAccCheckPagerDutyEventOrchestrationRouterExists("pagerduty_event_orchestration_router.router"),
resource.TestCheckResourceAttr(
"pagerduty_event_orchestration_router.router", "set.0.rule.0.disabled", "true"),
),
},
{
Config: testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfigUpdated(team, escalationPolicy, service, orchestration),
Check: resource.ComposeTestCheckFunc(
testAccCheckPagerDutyEventOrchestrationRouterExists("pagerduty_event_orchestration_router.router"),
resource.TestCheckResourceAttr(
"pagerduty_event_orchestration_router.router", "set.0.rule.0.disabled", "false"),
),
// This is unnecessary, because this is the default behaviour of all
// tests, it is only here to explicitely state that this is the expected
// outcome from test.
ExpectNonEmptyPlan: false,
},
},
})
}

func testAccCheckPagerDutyEventOrchestrationRouterDestroy(s *terraform.State) error {
client, _ := testAccProvider.Meta().(*Config).Client()
for _, r := range s.RootModule().Resources {
Expand Down Expand Up @@ -391,6 +426,54 @@ func testAccCheckPagerDutyEventOrchestrationRouterConfigDeleteAllRulesInSet(t, e
`)
}

func testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfig(t, ep, s, o string) string {
return fmt.Sprintf("%s%s", createBaseConfig(t, ep, s, o),
`resource "pagerduty_event_orchestration_router" "router" {
event_orchestration = pagerduty_event_orchestration.orch.id
catch_all {
actions {
route_to = "unrouted"
}
}
set {
id = "start"
rule {
disabled = true
label = "rule1 label"
actions {
route_to = pagerduty_service.bar.id
}
}
}
}
`)
}

func testAccCheckPagerDutyEventOrchestrationRouterEnableRoutingRuleConfigUpdated(t, ep, s, o string) string {
return fmt.Sprintf("%s%s", createBaseConfig(t, ep, s, o),
`resource "pagerduty_event_orchestration_router" "router" {
event_orchestration = pagerduty_event_orchestration.orch.id
catch_all {
actions {
route_to = "unrouted"
}
}
set {
id = "start"
rule {
disabled = false
label = "rule1 label"
actions {
route_to = pagerduty_service.bar.id
}
}
}
}
`)
}

func testAccCheckPagerDutyEventOrchestrationRouterConfigDelete(t, ep, s, o string) string {
return createBaseConfig(t, ep, s, o)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ github.com/hashicorp/terraform-svchost
# github.com/hashicorp/yamux v0.1.1
## explicit; go 1.15
github.com/hashicorp/yamux
# github.com/heimweh/go-pagerduty v0.0.0-20231212192829-0de11cddf326
# github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76
## explicit; go 1.17
github.com/heimweh/go-pagerduty/pagerduty
github.com/heimweh/go-pagerduty/persistentconfig
Expand Down

0 comments on commit 4d2a0b7

Please sign in to comment.