Skip to content

Commit

Permalink
fix(tests): add more dedup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Oct 26, 2019
1 parent ff1d69f commit 5591c58
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions internal/alertmanager/dedup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ func TestDedupAlertsWithoutLabels(t *testing.T) {
}
}

func TestDedupSilences(t *testing.T) {
os.Setenv("ALERTMANAGER_URI", "http://localhost")
config.Config.Read()
if err := pullAlerts(); err != nil {
t.Error(err)
}
silences := alertmanager.DedupSilences()
expected := 72
if len(silences) != expected {
t.Errorf("Expected %d silences keys, got %d", expected, len(silences))
}
}

func TestDedupAutocomplete(t *testing.T) {
if err := pullAlerts(); err != nil {
t.Error(err)
Expand Down Expand Up @@ -121,6 +134,32 @@ func TestDedupColors(t *testing.T) {
}
}

func TestDedupKnownLabels(t *testing.T) {
os.Setenv("ALERTMANAGER_URI", "http://localhost")
config.Config.Read()
if err := pullAlerts(); err != nil {
t.Error(err)
}
labels := alertmanager.DedupKnownLabels()
expected := 6
if len(labels) != expected {
t.Errorf("Expected %d knownLabels keys, got %d", expected, len(labels))
}
}

func TestDedupKnownLabelValues(t *testing.T) {
os.Setenv("ALERTMANAGER_URI", "http://localhost")
config.Config.Read()
if err := pullAlerts(); err != nil {
t.Error(err)
}
values := alertmanager.DedupKnownLabelValues("alertname")
expected := 4
if len(values) != expected {
t.Errorf("Expected %d knownLabelValues keys, got %d", expected, len(values))
}
}

func TestStripReceivers(t *testing.T) {
os.Setenv("RECEIVERS_STRIP", "by-name by-cluster-service")
os.Setenv("ALERTMANAGER_URI", "http://localhost")
Expand Down

0 comments on commit 5591c58

Please sign in to comment.