Alerting: Fix TestIntegration_GetAlertRulesForScheduling to make sure rules are created in different org (#69088)

make sure rules are created in different org
This commit is contained in:
Yuri Tseretyan
2023-05-25 13:51:38 -04:00
committed by GitHub
parent 1eed40fcf6
commit b57ef1f2c7
2 changed files with 28 additions and 11 deletions
+15
View File
@@ -140,6 +140,21 @@ func WithOrgID(orgId int64) AlertRuleMutator {
}
}
func WithUniqueOrgID() AlertRuleMutator {
orgs := map[int64]struct{}{}
return func(rule *AlertRule) {
var orgID int64
for {
orgID = rand.Int63()
if _, ok := orgs[orgID]; !ok {
break
}
}
orgs[orgID] = struct{}{}
rule.OrgID = orgID
}
}
func WithNamespace(namespace *folder.Folder) AlertRuleMutator {
return func(rule *AlertRule) {
rule.NamespaceUID = namespace.UID