mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
This reverts commit d652d035ab
.
This commit is contained in:
parent
d652d035ab
commit
cbf30aac82
@ -168,7 +168,7 @@ func (pn *PagerdutyNotifier) buildEventPayload(evalContext *alerting.EvalContext
|
||||
}
|
||||
|
||||
var summary string
|
||||
if pn.MessageInDetails || evalContext.Rule.Message == "" {
|
||||
if pn.MessageInDetails {
|
||||
summary = evalContext.Rule.Name
|
||||
} else {
|
||||
summary = evalContext.Rule.Name + " - " + evalContext.Rule.Message
|
||||
|
@ -173,60 +173,6 @@ func TestPagerdutyNotifier(t *testing.T) {
|
||||
So(diff, ShouldBeEmpty)
|
||||
})
|
||||
|
||||
Convey("should return properly formatted default v2 event payload with empty message", func() {
|
||||
json := `{
|
||||
"integrationKey": "abcdefgh0123456789",
|
||||
"autoResolve": false
|
||||
}`
|
||||
|
||||
settingsJSON, err := simplejson.NewJson([]byte(json))
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
model := &models.AlertNotification{
|
||||
Name: "pagerduty_testing",
|
||||
Type: "pagerduty",
|
||||
Settings: settingsJSON,
|
||||
}
|
||||
|
||||
not, err := NewPagerdutyNotifier(model)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
pagerdutyNotifier := not.(*PagerdutyNotifier)
|
||||
evalContext := alerting.NewEvalContext(context.Background(), &alerting.Rule{
|
||||
ID: 0,
|
||||
Name: "someRule",
|
||||
State: models.AlertStateAlerting,
|
||||
}, &validations.OSSPluginRequestValidator{})
|
||||
evalContext.IsTestRun = true
|
||||
|
||||
payloadJSON, err := pagerdutyNotifier.buildEventPayload(evalContext)
|
||||
So(err, ShouldBeNil)
|
||||
payload, err := simplejson.NewJson(payloadJSON)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
diff := cmp.Diff(map[string]interface{}{
|
||||
"client": "Grafana",
|
||||
"client_url": "",
|
||||
"dedup_key": "alertId-0",
|
||||
"event_action": "trigger",
|
||||
"links": []interface{}{
|
||||
map[string]interface{}{
|
||||
"href": "",
|
||||
},
|
||||
},
|
||||
"payload": map[string]interface{}{
|
||||
"component": "Grafana",
|
||||
"source": "<<PRESENCE>>",
|
||||
"custom_details": map[string]interface{}{},
|
||||
"severity": "critical",
|
||||
"summary": "someRule",
|
||||
"timestamp": "<<PRESENCE>>",
|
||||
},
|
||||
"routing_key": "abcdefgh0123456789",
|
||||
}, payload.Interface(), cmp.Comparer(presenceComparer))
|
||||
So(diff, ShouldBeEmpty)
|
||||
})
|
||||
|
||||
Convey("should return properly formatted payload with message moved to details", func() {
|
||||
json := `{
|
||||
"integrationKey": "abcdefgh0123456789",
|
||||
|
Loading…
Reference in New Issue
Block a user