mirror of
https://github.com/prymitive/karma
synced 2026-08-28 11:17:28 +00:00
fix(tests): correctly setup silences for filter tests
ft.Silence is not a pointer so it's never null, fix the check to use the ID which will default to empty string if Silence object is not populated
This commit is contained in:
@@ -552,16 +552,16 @@ func TestFilters(t *testing.T) {
|
||||
}
|
||||
for _, ft := range tests {
|
||||
alert := models.Alert(ft.Alert)
|
||||
if &ft.Silence != nil {
|
||||
alert.Alertmanager = []models.AlertmanagerInstance{
|
||||
models.AlertmanagerInstance{
|
||||
Name: am.Name,
|
||||
Silences: map[string]*models.Silence{
|
||||
ft.Silence.ID: &ft.Silence,
|
||||
},
|
||||
SilencedBy: []string{ft.Silence.ID},
|
||||
},
|
||||
}
|
||||
alert.Alertmanager = []models.AlertmanagerInstance{
|
||||
models.AlertmanagerInstance{
|
||||
Name: am.Name,
|
||||
Silences: map[string]*models.Silence{},
|
||||
SilencedBy: []string{},
|
||||
},
|
||||
}
|
||||
if ft.Silence.ID != "" {
|
||||
alert.Alertmanager[0].Silences[ft.Silence.ID] = &ft.Silence
|
||||
alert.Alertmanager[0].SilencedBy = append(alert.Alertmanager[0].SilencedBy, ft.Silence.ID)
|
||||
}
|
||||
|
||||
f := filters.NewFilter(ft.Expression)
|
||||
|
||||
Reference in New Issue
Block a user