notifications_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package notifications
  2. import (
  3. "testing"
  4. m "github.com/grafana/grafana/pkg/models"
  5. "github.com/grafana/grafana/pkg/setting"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. type testTriggeredAlert struct {
  9. ActualValue float64
  10. Name string
  11. State string
  12. }
  13. func TestNotifications(t *testing.T) {
  14. Convey("Given the notifications service", t, func() {
  15. //bus.ClearBusHandlers()
  16. setting.StaticRootPath = "../../../public/"
  17. setting.Smtp.Enabled = true
  18. setting.Smtp.TemplatesPattern = "emails/*.html"
  19. setting.Smtp.FromAddress = "from@address.com"
  20. err := Init()
  21. So(err, ShouldBeNil)
  22. var sentMsg *Message
  23. addToMailQueue = func(msg *Message) {
  24. sentMsg = msg
  25. }
  26. Convey("When sending reset email password", func() {
  27. err := sendResetPasswordEmail(&m.SendResetPasswordEmailCommand{User: &m.User{Email: "asd@asd.com"}})
  28. So(err, ShouldBeNil)
  29. So(sentMsg.Body, ShouldContainSubstring, "body")
  30. So(sentMsg.Subject, ShouldEqual, "Reset your Grafana password - asd@asd.com")
  31. So(sentMsg.Body, ShouldNotContainSubstring, "Subject")
  32. })
  33. })
  34. }