|
@@ -47,6 +47,33 @@ func TestEmailNotifier(t *testing.T) {
|
|
|
So(emailNotifier.Type, ShouldEqual, "email")
|
|
So(emailNotifier.Type, ShouldEqual, "email")
|
|
|
So(emailNotifier.Addresses[0], ShouldEqual, "ops@grafana.org")
|
|
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")
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|