mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 19:14:19 +08:00

* tech(routines): move the async logic from notification to alerting notifier * tech(notification): reduce code dupe * fix(notification): dont touch the response unless its an error * feat(alerting): make alerting exeuction async but flow sync * tech(alerting): remove commented code * tech(alerting): remove unused code * tech(alerting): fix typo * tech(alerting): implement Context on EvalContext * tech(alerting): wait for all alerts to return * feat(alerting): dont allow alert responses to cancel * Revert "feat(alerting): dont allow alert responses to cancel" This reverts commit 324b006c96687da18a542942f39c10c99119430c. * feat(alerting): give alerts some time to finish before closing down
46 lines
928 B
Go
46 lines
928 B
Go
package alerting
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
type conditionStub struct {
|
|
firing bool
|
|
}
|
|
|
|
func (c *conditionStub) Eval(context *EvalContext) {
|
|
context.Firing = c.firing
|
|
}
|
|
|
|
func TestAlertingExecutor(t *testing.T) {
|
|
Convey("Test alert execution", t, func() {
|
|
handler := NewEvalHandler()
|
|
|
|
Convey("Show return triggered with single passing condition", func() {
|
|
context := NewEvalContext(context.TODO(), &Rule{
|
|
Conditions: []Condition{&conditionStub{
|
|
firing: true,
|
|
}},
|
|
})
|
|
|
|
handler.Eval(context)
|
|
So(context.Firing, ShouldEqual, true)
|
|
})
|
|
|
|
Convey("Show return false with not passing condition", func() {
|
|
context := NewEvalContext(context.TODO(), &Rule{
|
|
Conditions: []Condition{
|
|
&conditionStub{firing: true},
|
|
&conditionStub{firing: false},
|
|
},
|
|
})
|
|
|
|
handler.Eval(context)
|
|
So(context.Firing, ShouldEqual, false)
|
|
})
|
|
})
|
|
}
|