-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Closes #1601 When deleting a mute timing, the provider has to start with removing it from all notification policies where it's in-use
- Loading branch information
1 parent
5b3d094
commit ccf90e3
Showing
2 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,3 +107,59 @@ resource "grafana_mute_timing" "my_mute_timing" { | |
}, | ||
}) | ||
} | ||
|
||
func TestAccMuteTiming_RemoveInUse(t *testing.T) { | ||
testutils.CheckOSSTestsEnabled(t, ">9.0.0") | ||
|
||
config := func(mute bool) string { | ||
return fmt.Sprintf(` | ||
locals { | ||
use_mute = %t | ||
} | ||
resource "grafana_organization" "my_org" { | ||
name = "mute-timing-test" | ||
} | ||
resource "grafana_contact_point" "default_policy" { | ||
org_id = grafana_organization.my_org.id | ||
name = "default-policy" | ||
email { | ||
addresses = ["[email protected]"] | ||
} | ||
} | ||
resource "grafana_notification_policy" "org_policy" { | ||
org_id = grafana_organization.my_org.id | ||
group_by = ["..."] | ||
group_wait = "45s" | ||
group_interval = "6m" | ||
repeat_interval = "3h" | ||
contact_point = grafana_contact_point.default_policy.name | ||
policy { | ||
mute_timings = local.use_mute ? [grafana_mute_timing.test[0].name] : [] | ||
contact_point = grafana_contact_point.default_policy.name | ||
} | ||
} | ||
resource "grafana_mute_timing" "test" { | ||
count = local.use_mute ? 1 : 0 | ||
org_id = grafana_organization.my_org.id | ||
name = "test-mute-timing" | ||
intervals {} | ||
}`, mute) | ||
} | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
ProtoV5ProviderFactories: testutils.ProtoV5ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config(true), | ||
}, | ||
{ | ||
Config: config(false), | ||
}, | ||
}, | ||
}) | ||
} |