From 0fa3568e5ffb71bbc314724b492cbae7512b8b3a Mon Sep 17 00:00:00 2001 From: Josh Moon Date: Wed, 8 Jan 2025 10:01:18 -0500 Subject: [PATCH] remove value check on conditional and update tests --- ...rce_pagerduty_incident_workflow_trigger.go | 3 - ...agerduty_incident_workflow_trigger_test.go | 56 +++++++++++-------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/pagerduty/resource_pagerduty_incident_workflow_trigger.go b/pagerduty/resource_pagerduty_incident_workflow_trigger.go index bdf9423fe..0bcedd1f7 100644 --- a/pagerduty/resource_pagerduty_incident_workflow_trigger.go +++ b/pagerduty/resource_pagerduty_incident_workflow_trigger.go @@ -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) diff --git a/pagerduty/resource_pagerduty_incident_workflow_trigger_test.go b/pagerduty/resource_pagerduty_incident_workflow_trigger_test.go index b20eed3e2..2ce0b2dc7 100644 --- a/pagerduty/resource_pagerduty_incident_workflow_trigger_test.go +++ b/pagerduty/resource_pagerduty_incident_workflow_trigger_test.go @@ -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" { @@ -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( @@ -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( @@ -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(