Merge branch 'master' into react-mobx

This commit is contained in:
Torkel Ödegaard
2017-12-26 13:53:39 +01:00
27 changed files with 759 additions and 602 deletions

View File

@@ -42,7 +42,7 @@ var (
)
func NewPagerdutyNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
autoResolve := model.Settings.Get("autoResolve").MustBool(true)
autoResolve := model.Settings.Get("autoResolve").MustBool(false)
key := model.Settings.Get("integrationKey").MustString()
if key == "" {
return nil, alerting.ValidationError{Reason: "Could not find integration key property in settings"}

View File

@@ -10,7 +10,6 @@ import (
func TestPagerdutyNotifier(t *testing.T) {
Convey("Pagerduty notifier tests", t, func() {
Convey("Parsing alert notification from settings", func() {
Convey("empty settings should return error", func() {
json := `{ }`
@@ -26,10 +25,31 @@ func TestPagerdutyNotifier(t *testing.T) {
So(err, ShouldNotBeNil)
})
Convey("auto resolve should default to false", func() {
json := `{ "integrationKey": "abcdefgh0123456789" }`
settingsJSON, _ := simplejson.NewJson([]byte(json))
model := &m.AlertNotification{
Name: "pagerduty_testing",
Type: "pagerduty",
Settings: settingsJSON,
}
not, err := NewPagerdutyNotifier(model)
pagerdutyNotifier := not.(*PagerdutyNotifier)
So(err, ShouldBeNil)
So(pagerdutyNotifier.Name, ShouldEqual, "pagerduty_testing")
So(pagerdutyNotifier.Type, ShouldEqual, "pagerduty")
So(pagerdutyNotifier.Key, ShouldEqual, "abcdefgh0123456789")
So(pagerdutyNotifier.AutoResolve, ShouldBeFalse)
})
Convey("settings should trigger incident", func() {
json := `
{
"integrationKey": "abcdefgh0123456789"
"integrationKey": "abcdefgh0123456789",
"autoResolve": false
}`
settingsJSON, _ := simplejson.NewJson([]byte(json))
@@ -46,8 +66,8 @@ func TestPagerdutyNotifier(t *testing.T) {
So(pagerdutyNotifier.Name, ShouldEqual, "pagerduty_testing")
So(pagerdutyNotifier.Type, ShouldEqual, "pagerduty")
So(pagerdutyNotifier.Key, ShouldEqual, "abcdefgh0123456789")
So(pagerdutyNotifier.AutoResolve, ShouldBeFalse)
})
})
})
}