package aggregate import "testing" func TestEffectiveConnectionsBad(t *testing.T) { h := &Handler{} if got := h.effectiveConnectionsBad("a", 500); got != 500 { t.Fatalf("without baseline want 500, got %d", got) } h.setBadConnectionBaseline("a", 400) if got := h.effectiveConnectionsBad("a", 900); got != 500 { t.Fatalf("with baseline 400 want delta 500, got %d", got) } h.setBadConnectionBaseline("b", 1000) if got := h.effectiveConnectionsBad("b", 500); got != 500 { t.Fatalf("after counter drop want raw value 500, got %d", got) } if _, ok := h.badConnBaseline["b"]; ok { t.Fatal("baseline for b should be cleared when current < baseline") } }