Add a test for total number of alerts we get from mock, should be 24

This commit is contained in:
Łukasz Mierzwa
2017-08-10 22:22:01 -07:00
parent 549ff9eefd
commit d1d4a85409

View File

@@ -35,9 +35,39 @@ func TestDedupAlerts(t *testing.T) {
t.Error(err)
}
alertGroups := alertmanager.DedupAlerts()
if len(alertGroups) != 10 {
t.Errorf("Expected %d alert groups, got %d", 10, len(alertGroups))
}
totalAlerts := 0
for _, ag := range alertGroups {
totalAlerts += len(ag.Alerts)
}
if totalAlerts != 24 {
t.Errorf("Expected %d total alerts, got %d", 24, totalAlerts)
}
}
func TestDedupAlertsWithoutLabels(t *testing.T) {
config.Config.KeepLabels = []string{"xyz"}
if err := pullAlerts(); err != nil {
t.Error(err)
}
alertGroups := alertmanager.DedupAlerts()
config.Config.KeepLabels = []string{}
if len(alertGroups) != 10 {
t.Errorf("Expected %d alert groups, got %d", 10, len(alertGroups))
}
totalAlerts := 0
for _, ag := range alertGroups {
totalAlerts += len(ag.Alerts)
}
if totalAlerts != 24 {
t.Errorf("Expected %d total alerts, got %d", 24, totalAlerts)
}
}
func TestDedupAutocomplete(t *testing.T) {