base_test.go 839 B

123456789101112131415161718192021222324252627282930313233343536
  1. package notifiers
  2. import (
  3. "testing"
  4. "github.com/grafana/grafana/pkg/components/simplejson"
  5. m "github.com/grafana/grafana/pkg/models"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestBaseNotifier(t *testing.T) {
  9. Convey("Parsing base notification severity", t, func() {
  10. Convey("matches", func() {
  11. json := `
  12. {
  13. "severityFilter": "critical"
  14. }`
  15. settingsJSON, _ := simplejson.NewJson([]byte(json))
  16. not := NewNotifierBase("ops", "email", settingsJSON)
  17. So(not.MatchSeverity(m.AlertSeverityCritical), ShouldBeTrue)
  18. })
  19. Convey("does not match", func() {
  20. json := `
  21. {
  22. "severityFilter": "critical"
  23. }`
  24. settingsJSON, _ := simplejson.NewJson([]byte(json))
  25. not := NewNotifierBase("ops", "email", settingsJSON)
  26. So(not.MatchSeverity(m.AlertSeverityWarning), ShouldBeFalse)
  27. })
  28. })
  29. }