2015-06-05 04:08:19 -05:00
|
|
|
package notifications
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
)
|
|
|
|
|
2016-06-17 08:30:17 -05:00
|
|
|
type testTriggeredAlert struct {
|
|
|
|
ActualValue float64
|
|
|
|
Name string
|
|
|
|
State string
|
|
|
|
}
|
|
|
|
|
2015-06-05 04:08:19 -05:00
|
|
|
func TestNotifications(t *testing.T) {
|
|
|
|
|
|
|
|
Convey("Given the notifications service", t, func() {
|
2016-10-03 02:38:03 -05:00
|
|
|
//bus.ClearBusHandlers()
|
2015-06-05 04:08:19 -05:00
|
|
|
|
|
|
|
setting.StaticRootPath = "../../../public/"
|
2015-06-08 11:25:04 -05:00
|
|
|
setting.Smtp.Enabled = true
|
|
|
|
setting.Smtp.TemplatesPattern = "emails/*.html"
|
2015-06-05 04:08:19 -05:00
|
|
|
setting.Smtp.FromAddress = "from@address.com"
|
2017-02-14 15:04:21 -06:00
|
|
|
setting.Smtp.FromName = "Grafana Admin"
|
2015-06-05 04:08:19 -05:00
|
|
|
|
|
|
|
err := Init()
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
2015-06-08 09:51:25 -05:00
|
|
|
var sentMsg *Message
|
|
|
|
addToMailQueue = func(msg *Message) {
|
|
|
|
sentMsg = msg
|
2015-06-05 04:08:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Convey("When sending reset email password", func() {
|
2015-06-08 11:25:04 -05:00
|
|
|
err := sendResetPasswordEmail(&m.SendResetPasswordEmailCommand{User: &m.User{Email: "asd@asd.com"}})
|
|
|
|
So(err, ShouldBeNil)
|
2015-06-08 09:51:25 -05:00
|
|
|
So(sentMsg.Body, ShouldContainSubstring, "body")
|
2015-06-13 23:08:18 -05:00
|
|
|
So(sentMsg.Subject, ShouldEqual, "Reset your Grafana password - asd@asd.com")
|
2015-06-08 09:51:25 -05:00
|
|
|
So(sentMsg.Body, ShouldNotContainSubstring, "Subject")
|
2015-06-05 04:08:19 -05:00
|
|
|
})
|
2016-06-17 08:30:17 -05:00
|
|
|
})
|
2015-06-05 04:08:19 -05:00
|
|
|
}
|