logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

mailer_test.exs (1457B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Emails.MailerTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Emails.Mailer
  7. import Swoosh.TestAssertions
  8. @email %Swoosh.Email{
  9. from: {"Pleroma", "noreply@example.com"},
  10. html_body: "Test email",
  11. subject: "Pleroma test email",
  12. to: [{"Test User", "user1@example.com"}]
  13. }
  14. setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
  15. test "not send email when mailer is disabled" do
  16. clear_config([Pleroma.Emails.Mailer, :enabled], false)
  17. Mailer.deliver(@email)
  18. :timer.sleep(100)
  19. refute_email_sent(
  20. from: {"Pleroma", "noreply@example.com"},
  21. to: [{"Test User", "user1@example.com"}],
  22. html_body: "Test email",
  23. subject: "Pleroma test email"
  24. )
  25. end
  26. test "send email" do
  27. Mailer.deliver(@email)
  28. :timer.sleep(100)
  29. assert_email_sent(
  30. from: {"Pleroma", "noreply@example.com"},
  31. to: [{"Test User", "user1@example.com"}],
  32. html_body: "Test email",
  33. subject: "Pleroma test email"
  34. )
  35. end
  36. test "perform" do
  37. Mailer.perform(:deliver_async, @email, [])
  38. :timer.sleep(100)
  39. assert_email_sent(
  40. from: {"Pleroma", "noreply@example.com"},
  41. to: [{"Test User", "user1@example.com"}],
  42. html_body: "Test email",
  43. subject: "Pleroma test email"
  44. )
  45. end
  46. end