base_test.go 814 B

1234567891011121314151617181920212223242526272829303132
  1. package notifiers
  2. import (
  3. "context"
  4. "testing"
  5. m "github.com/grafana/grafana/pkg/models"
  6. "github.com/grafana/grafana/pkg/services/alerting"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestBaseNotifier(t *testing.T) {
  10. Convey("Base notifier tests", t, func() {
  11. Convey("should notify", func() {
  12. Convey("pending -> ok", func() {
  13. context := alerting.NewEvalContext(context.TODO(), &alerting.Rule{
  14. State: m.AlertStatePending,
  15. })
  16. context.Rule.State = m.AlertStateOK
  17. So(defaultShouldNotify(context), ShouldBeFalse)
  18. })
  19. Convey("ok -> alerting", func() {
  20. context := alerting.NewEvalContext(context.TODO(), &alerting.Rule{
  21. State: m.AlertStateOK,
  22. })
  23. context.Rule.State = m.AlertStateAlerting
  24. So(defaultShouldNotify(context), ShouldBeTrue)
  25. })
  26. })
  27. })
  28. }