package rules import ( "testing" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/promql" ) func TestAlertingRuleHTMLSnippet(t *testing.T) { expr, err := promql.ParseExpr(`foo{html="BOLD"}`) if err != nil { t.Fatal(err) } rule := NewAlertingRule("testrule", expr, 0, model.LabelSet{"html": "BOLD"}, model.LabelSet{"html": "BOLD"}) const want = `ALERT testrule IF foo{html="<b>BOLD<b>"} LABELS {html="<b>BOLD</b>"} ANNOTATIONS {html="<b>BOLD</b>"}` got := rule.HTMLSnippet("/test/prefix") if got != want { t.Fatalf("incorrect HTML snippet; want:\n\n|%v|\n\ngot:\n\n|%v|", want, got) } }