carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "strings"
5 "testing"
6 "time"
7
8 "github.com/carlosframework/platform/internal/metrics"
9)
10
11func TestGeoIPAlertSentences(t *testing.T) {
12 for code, want := range map[float64]string{
13 1: "more than 45 days old", 2: "expires within 9 days", 3: "has expired and was removed",
14 4: "has not loaded the published geoip database", 5: "has failed 7 times in a row",
15 } {
16 if got := alertSentence(metrics.Event{Rule: "geoip", Firing: true, Value: code, Box: "b"}); !strings.Contains(got, want) {
17 t.Errorf("code %v = %q, want %q", code, got, want)
18 }
19 }
20 if got := alertClearSentence(metrics.Event{Rule: "geoip", Box: "b"}); got != "geoip on b is back to normal" {
21 t.Errorf("clear = %q", got)
22 }
23 if geoIPAlertReading(time.Now()) != nil {
24 t.Error("no edge published must mean no reading")
25 }
26}
27