notifications_test.go 898 B

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