mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -06:00
fa7d7ed5df
* wip: start on refactoring settings * settings: progress on settings refactor * refactor: progress on settings refactoring * fix: fixed failing test * settings: moved smtp settings from global to instance
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package notifications
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/bus"
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
type testTriggeredAlert struct {
|
|
ActualValue float64
|
|
Name string
|
|
State string
|
|
}
|
|
|
|
func TestNotifications(t *testing.T) {
|
|
|
|
Convey("Given the notifications service", t, func() {
|
|
setting.StaticRootPath = "../../../public/"
|
|
|
|
ns := &NotificationService{}
|
|
ns.Bus = bus.New()
|
|
ns.Cfg = setting.NewCfg()
|
|
ns.Cfg.Smtp.Enabled = true
|
|
ns.Cfg.Smtp.TemplatesPattern = "emails/*.html"
|
|
ns.Cfg.Smtp.FromAddress = "from@address.com"
|
|
ns.Cfg.Smtp.FromName = "Grafana Admin"
|
|
|
|
err := ns.Init()
|
|
So(err, ShouldBeNil)
|
|
|
|
Convey("When sending reset email password", func() {
|
|
err := ns.sendResetPasswordEmail(&m.SendResetPasswordEmailCommand{User: &m.User{Email: "asd@asd.com"}})
|
|
So(err, ShouldBeNil)
|
|
|
|
sentMsg := <-ns.mailQueue
|
|
So(sentMsg.Body, ShouldContainSubstring, "body")
|
|
So(sentMsg.Subject, ShouldEqual, "Reset your Grafana password - asd@asd.com")
|
|
So(sentMsg.Body, ShouldNotContainSubstring, "Subject")
|
|
})
|
|
})
|
|
}
|