fix(alerting): use uid and not rand() in tests for title (#85001)

This commit is contained in:
Jean-Philippe Quéméner 2024-03-22 15:26:09 +01:00 committed by GitHub
parent a2facbecd4
commit f2c7023fe6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,6 +44,7 @@ func config(t *testing.T) *setting.UnifiedAlertingSettings {
func validRule() apimodels.PostableExtendedRuleNode {
forDuration := model.Duration(rand.Int63n(1000))
uid := util.GenerateShortUID()
return apimodels.PostableExtendedRuleNode{
ApiRuleNode: &apimodels.ApiRuleNode{
For: &forDuration,
@ -55,7 +56,7 @@ func validRule() apimodels.PostableExtendedRuleNode {
},
},
GrafanaManagedAlert: &apimodels.PostableGrafanaRule{
Title: fmt.Sprintf("TEST-ALERT-%d", rand.Int63()),
Title: fmt.Sprintf("TEST-ALERT-%s", uid),
Condition: "A",
Data: []apimodels.AlertQuery{
{
@ -69,7 +70,7 @@ func validRule() apimodels.PostableExtendedRuleNode {
Model: nil,
},
},
UID: util.GenerateShortUID(),
UID: uid,
NoDataState: allNoData[rand.Intn(len(allNoData))],
ExecErrState: allExecError[rand.Intn(len(allExecError))],
},