Improve resource/pagerduty_schedule
open incidents handling on deletion
#681
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Complements #679
Some users where reporting that the inclusion of
UserIDs
as an additional query param for targeting the incidents was generating error on the retries for listing open incidents. So, this update is addressing that issue.Additionally, I took the chance for moving the incident query to happen when a 400 error is received and it's also containing an expected message, to make the call for the open incidents, which turns out to be more efficient than making the call each time a Schedule was trying to be deleted.
Finally, I extended the test case covering the case when an unrelated incident get created and assigned to the same user in the Schedule that's going to be deleted, but the user received the incident assignment because of a different Escalation Policy, and this latter is not using the above mentioned Schedule.
Test cases extended...