send_email_integration_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package notifications
  2. import (
  3. "io/ioutil"
  4. "testing"
  5. "github.com/grafana/grafana/pkg/bus"
  6. m "github.com/grafana/grafana/pkg/models"
  7. "github.com/grafana/grafana/pkg/setting"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestEmailIntegrationTest(t *testing.T) {
  11. SkipConvey("Given the notifications service", t, func() {
  12. bus.ClearBusHandlers()
  13. setting.StaticRootPath = "../../../public/"
  14. setting.Smtp.Enabled = true
  15. setting.Smtp.TemplatesPattern = "emails/*.html"
  16. setting.Smtp.FromAddress = "from@address.com"
  17. setting.BuildVersion = "4.0.0"
  18. err := Init()
  19. So(err, ShouldBeNil)
  20. addToMailQueue = func(msg *Message) {
  21. ioutil.WriteFile("../../../tmp/test_email.html", []byte(msg.Body), 0777)
  22. }
  23. Convey("When sending reset email password", func() {
  24. cmd := &m.SendEmailCommand{
  25. Data: map[string]interface{}{
  26. "Title": "[CRITICAL] Imaginary timeserie alert",
  27. "State": "Firing",
  28. "Name": "Imaginary timeserie alert",
  29. "Severity": "Critical",
  30. "Message": "Alert message that will support markdown in some distant future.",
  31. "RuleUrl": "http://localhost:3000/dashboard/db/graphite-dashboard",
  32. "AlertPageUrl": "http://localhost:3000/alerting",
  33. "ImageLink": "http://localhost:3000/render/dashboard-solo/db/graphite-dashboard?panelId=1&from=1471008499616&to=1471012099617&width=1000&height=500",
  34. "SeverityColor": "#D63232",
  35. },
  36. To: []string{"asdf@asdf.com "},
  37. Template: "alert_notification.html",
  38. }
  39. err := sendEmailCommandHandler(cmd)
  40. So(err, ShouldBeNil)
  41. })
  42. })
  43. }