send_email_integration_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. err := Init()
  18. So(err, ShouldBeNil)
  19. addToMailQueue = func(msg *Message) {
  20. ioutil.WriteFile("../../../tmp/test_email.html", []byte(msg.Body), 0777)
  21. }
  22. Convey("When sending reset email password", func() {
  23. cmd := &m.SendEmailCommand{
  24. Data: map[string]interface{}{
  25. "Name": "Name",
  26. "State": "Critical",
  27. "Description": "Description",
  28. "DashboardLink": "http://localhost:3000/dashboard/db/alerting",
  29. "AlertPageUrl": "http://localhost:3000/alerting",
  30. "DashboardImage": "http://localhost:3000/render/dashboard-solo/db/alerting?from=1466169458375&to=1466171258375&panelId=3&width=1000&height=500",
  31. "TriggeredAlerts": []testTriggeredAlert{
  32. {Name: "desktop", State: "Critical", ActualValue: 13},
  33. {Name: "mobile", State: "Warn", ActualValue: 5},
  34. },
  35. },
  36. To: []string{"asd@asd.com "},
  37. Template: "alert_notification.html",
  38. }
  39. err := sendEmailCommandHandler(cmd)
  40. So(err, ShouldBeNil)
  41. })
  42. })
  43. }