Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pagerduty_incident_workflow_trigger remove value check on conditional and update tests #964

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pagerduty/resource_pagerduty_incident_workflow_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ func validateIncidentWorkflowTrigger(_ context.Context, d *schema.ResourceDiff,
if triggerType == "manual" && hadCondition {
return fmt.Errorf("when trigger type manual is used, condition must not be specified")
}
if triggerType == "conditional" && !hadCondition {
return fmt.Errorf("when trigger type conditional is used, condition must be specified")
}

// pagerduty_incident_workflow_trigger.permissions input validation
permissionRestricted := d.Get("permissions.0.restricted").(bool)
Expand Down
56 changes: 33 additions & 23 deletions pagerduty/resource_pagerduty_incident_workflow_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,6 @@ resource "pagerduty_incident_workflow_trigger" "my_first_workflow_trigger" {
})
}

func TestAccPagerDutyIncidentWorkflowTrigger_ConditionalTypeWithoutCondition(t *testing.T) {
config := `
resource "pagerduty_incident_workflow_trigger" "my_first_workflow_trigger" {
type = "conditional"
workflow = "ignored"
subscribed_to_all_services = true
}
`
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccPreCheckIncidentWorkflows(t)
},
ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: config,
ExpectError: regexp.MustCompile("when trigger type conditional is used, condition must be specified"),
},
},
})
}

func TestAccPagerDutyIncidentWorkflowTrigger_SubscribedToAllWithInvalidServices(t *testing.T) {
config := `
resource "pagerduty_incident_workflow_trigger" "my_first_workflow_trigger" {
Expand Down Expand Up @@ -203,6 +180,17 @@ func TestAccPagerDutyIncidentWorkflowTrigger_BasicConditionalAllServices(t *test
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPagerDutyIncidentWorkflowTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyIncidentWorkflowTriggerConfigConditionalAllServices(workflow, ""),
Check: resource.ComposeTestCheckFunc(
testAccCheckPagerDutyIncidentWorkflowTriggerExists("pagerduty_incident_workflow_trigger.test"),
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow_trigger.test", "type", "conditional"),
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow_trigger.test", "condition", ""),
resource.TestCheckResourceAttr("pagerduty_incident_workflow_trigger.test", "subscribed_to_all_services", "true"),
),
},
{
Config: testAccCheckPagerDutyIncidentWorkflowTriggerConfigConditionalAllServices(workflow, "incident.priority matches 'P1'"),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -383,6 +371,17 @@ func TestAccPagerDutyIncidentWorkflowTrigger_ChangeTypeCausesReplace(t *testing.
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPagerDutyIncidentWorkflowTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyIncidentWorkflowTriggerConfigConditionalAllServices(workflow, ""),
Check: resource.ComposeTestCheckFunc(
testAccCheckPagerDutyIncidentWorkflowTriggerExists("pagerduty_incident_workflow_trigger.test"),
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow_trigger.test", "type", "conditional"),
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow_trigger.test", "condition", ""),
resource.TestCheckResourceAttr("pagerduty_incident_workflow_trigger.test", "subscribed_to_all_services", "true"),
),
},
{
Config: testAccCheckPagerDutyIncidentWorkflowTriggerConfigConditionalAllServices(workflow, "incident.priority matches 'P1'"),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -445,6 +444,17 @@ func TestAccPagerDutyIncidentWorkflowTrigger_CannotChangeType(t *testing.T) {
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckPagerDutyIncidentWorkflowTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyIncidentWorkflowTriggerConfigConditionalAllServices(workflow, ""),
Check: resource.ComposeTestCheckFunc(
testAccCheckPagerDutyIncidentWorkflowTriggerExists("pagerduty_incident_workflow_trigger.test"),
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow_trigger.test", "type", "conditional"),
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow_trigger.test", "condition", ""),
resource.TestCheckResourceAttr("pagerduty_incident_workflow_trigger.test", "subscribed_to_all_services", "true"),
),
},
{
Config: testAccCheckPagerDutyIncidentWorkflowTriggerConfigConditionalAllServices(workflow, "incident.priority matches 'P1'"),
Check: resource.ComposeTestCheckFunc(
Expand Down