mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 11:20:27 -06:00
41d432b5ae
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package notifiers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestGoogleChatNotifier(t *testing.T) {
|
|
Convey("Google Hangouts Chat notifier tests", t, func() {
|
|
Convey("Parsing alert notification from settings", func() {
|
|
Convey("empty settings should return error", func() {
|
|
json := `{ }`
|
|
|
|
settingsJSON, _ := simplejson.NewJson([]byte(json))
|
|
model := &models.AlertNotification{
|
|
Name: "ops",
|
|
Type: "googlechat",
|
|
Settings: settingsJSON,
|
|
}
|
|
|
|
_, err := newGoogleChatNotifier(model)
|
|
So(err, ShouldNotBeNil)
|
|
})
|
|
|
|
Convey("from settings", func() {
|
|
json := `
|
|
{
|
|
"url": "http://google.com"
|
|
}`
|
|
|
|
settingsJSON, _ := simplejson.NewJson([]byte(json))
|
|
model := &models.AlertNotification{
|
|
Name: "ops",
|
|
Type: "googlechat",
|
|
Settings: settingsJSON,
|
|
}
|
|
|
|
not, err := newGoogleChatNotifier(model)
|
|
webhookNotifier := not.(*GoogleChatNotifier)
|
|
|
|
So(err, ShouldBeNil)
|
|
So(webhookNotifier.Name, ShouldEqual, "ops")
|
|
So(webhookNotifier.Type, ShouldEqual, "googlechat")
|
|
So(webhookNotifier.URL, ShouldEqual, "http://google.com")
|
|
})
|
|
})
|
|
})
|
|
}
|