mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
fd633a1d5d
This way we are able to edit notification behavior per notifier. This would be usefull to let some notifiers send notifications, even when the state doesn't change, or with custom condition. Signed-off-by: Thibault Chataigner <t.chataigner@criteo.com>
33 lines
814 B
Go
33 lines
814 B
Go
package notifiers
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/alerting"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestBaseNotifier(t *testing.T) {
|
|
Convey("Base notifier tests", t, func() {
|
|
Convey("should notify", func() {
|
|
Convey("pending -> ok", func() {
|
|
context := alerting.NewEvalContext(context.TODO(), &alerting.Rule{
|
|
State: m.AlertStatePending,
|
|
})
|
|
context.Rule.State = m.AlertStateOK
|
|
So(defaultShouldNotify(context), ShouldBeFalse)
|
|
})
|
|
|
|
Convey("ok -> alerting", func() {
|
|
context := alerting.NewEvalContext(context.TODO(), &alerting.Rule{
|
|
State: m.AlertStateOK,
|
|
})
|
|
context.Rule.State = m.AlertStateAlerting
|
|
So(defaultShouldNotify(context), ShouldBeTrue)
|
|
})
|
|
})
|
|
})
|
|
}
|