mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
feat(notifications): switch to ; seperator
using \n caused problems with the json deserialisation. closes #6326
This commit is contained in:
parent
3ac38dfe70
commit
6ea0f0120e
@ -30,7 +30,7 @@ func NewEmailNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
|
||||
|
||||
return &EmailNotifier{
|
||||
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
|
||||
Addresses: strings.Split(addressesString, "\n"),
|
||||
Addresses: strings.Split(addressesString, `;`),
|
||||
log: log.New("alerting.notifier.email"),
|
||||
}, nil
|
||||
}
|
||||
|
@ -47,6 +47,33 @@ func TestEmailNotifier(t *testing.T) {
|
||||
So(emailNotifier.Type, ShouldEqual, "email")
|
||||
So(emailNotifier.Addresses[0], ShouldEqual, "ops@grafana.org")
|
||||
})
|
||||
|
||||
Convey("from settings with two emails", func() {
|
||||
json := `
|
||||
{
|
||||
"addresses": "ops@grafana.org;dev@grafana.org"
|
||||
}`
|
||||
|
||||
settingsJSON, err := simplejson.NewJson([]byte(json))
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
model := &m.AlertNotification{
|
||||
Name: "ops",
|
||||
Type: "email",
|
||||
Settings: settingsJSON,
|
||||
}
|
||||
|
||||
not, err := NewEmailNotifier(model)
|
||||
emailNotifier := not.(*EmailNotifier)
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(emailNotifier.Name, ShouldEqual, "ops")
|
||||
So(emailNotifier.Type, ShouldEqual, "email")
|
||||
So(len(emailNotifier.Addresses), ShouldEqual, 2)
|
||||
|
||||
So(emailNotifier.Addresses[0], ShouldEqual, "ops@grafana.org")
|
||||
So(emailNotifier.Addresses[1], ShouldEqual, "dev@grafana.org")
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user