2017-01-19 01:25:21 -06:00
|
|
|
package notifiers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
2019-05-14 01:15:05 -05:00
|
|
|
"github.com/grafana/grafana/pkg/models"
|
2017-01-19 01:25:21 -06:00
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLineNotifier(t *testing.T) {
|
|
|
|
Convey("Line notifier tests", t, func() {
|
|
|
|
Convey("empty settings should return error", func() {
|
|
|
|
json := `{ }`
|
|
|
|
|
|
|
|
settingsJSON, _ := simplejson.NewJson([]byte(json))
|
2019-05-14 01:15:05 -05:00
|
|
|
model := &models.AlertNotification{
|
2017-01-19 01:25:21 -06:00
|
|
|
Name: "line_testing",
|
|
|
|
Type: "line",
|
|
|
|
Settings: settingsJSON,
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := NewLINENotifier(model)
|
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
})
|
|
|
|
Convey("settings should trigger incident", func() {
|
|
|
|
json := `
|
|
|
|
{
|
|
|
|
"token": "abcdefgh0123456789"
|
|
|
|
}`
|
|
|
|
settingsJSON, _ := simplejson.NewJson([]byte(json))
|
2019-05-14 01:15:05 -05:00
|
|
|
model := &models.AlertNotification{
|
2017-01-19 01:25:21 -06:00
|
|
|
Name: "line_testing",
|
|
|
|
Type: "line",
|
|
|
|
Settings: settingsJSON,
|
|
|
|
}
|
|
|
|
|
|
|
|
not, err := NewLINENotifier(model)
|
|
|
|
lineNotifier := not.(*LineNotifier)
|
|
|
|
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(lineNotifier.Name, ShouldEqual, "line_testing")
|
|
|
|
So(lineNotifier.Type, ShouldEqual, "line")
|
|
|
|
So(lineNotifier.Token, ShouldEqual, "abcdefgh0123456789")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|