|
|
@@ -26,59 +26,10 @@ func TestPagerdutyNotifier(t *testing.T) {
|
|
|
So(err, ShouldNotBeNil)
|
|
|
})
|
|
|
|
|
|
- Convey("settings with only integrationKey should contain AlertStateAlerting", 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.AlertingStates, ShouldContain, m.AlertStateAlerting)
|
|
|
- })
|
|
|
-
|
|
|
- Convey("settings with alertOnNoData should contain AlertStateNoData too", func() {
|
|
|
- json := `
|
|
|
- {
|
|
|
- "integrationKey": "abcdefgh0123456789",
|
|
|
- "alertOnNoData": true
|
|
|
- }`
|
|
|
-
|
|
|
- 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.AlertingStates, ShouldContain, m.AlertStateNoData)
|
|
|
- So(pagerdutyNotifier.AlertingStates, ShouldContain, m.AlertStateAlerting)
|
|
|
- })
|
|
|
-
|
|
|
- Convey("settings with alertOnNoData, alertOnExecError should contain both", func() {
|
|
|
+ Convey("settings with alertOnExecError should trigger incident", func() {
|
|
|
json := `
|
|
|
{
|
|
|
"integrationKey": "abcdefgh0123456789",
|
|
|
- "alertOnNoData": true,
|
|
|
"alertOnExecError": true
|
|
|
}`
|
|
|
|
|
|
@@ -96,9 +47,7 @@ func TestPagerdutyNotifier(t *testing.T) {
|
|
|
So(pagerdutyNotifier.Name, ShouldEqual, "pagerduty_testing")
|
|
|
So(pagerdutyNotifier.Type, ShouldEqual, "pagerduty")
|
|
|
So(pagerdutyNotifier.Key, ShouldEqual, "abcdefgh0123456789")
|
|
|
- So(pagerdutyNotifier.AlertingStates, ShouldContain, m.AlertStateNoData)
|
|
|
- So(pagerdutyNotifier.AlertingStates, ShouldContain, m.AlertStateAlerting)
|
|
|
- So(pagerdutyNotifier.AlertingStates, ShouldContain, m.AlertStateExecError)
|
|
|
+ So(pagerdutyNotifier.AlertOnExecError, ShouldContain, true)
|
|
|
})
|
|
|
|
|
|
})
|