diff options
| author | Maksim Pechnikov <parallel588@gmail.com> | 2020-01-28 21:11:13 +0300 | 
|---|---|---|
| committer | Maksim Pechnikov <parallel588@gmail.com> | 2020-01-28 21:11:13 +0300 | 
| commit | ba5e8a644463a19b863e862def80adb6a5a1060b (patch) | |
| tree | b00fdfbfe13979454dcad185e8c0c7de237d8a0f /test/tasks | |
| parent | e442ea5722404ca551135b6f4767c016952bbda3 (diff) | |
| parent | f1d5c0f07963c23d264311985c21837b9b03fd5a (diff) | |
| download | pleroma-ba5e8a644463a19b863e862def80adb6a5a1060b.tar.gz pleroma-ba5e8a644463a19b863e862def80adb6a5a1060b.zip  | |
Merge branch 'develop' into issue/1276
Diffstat (limited to 'test/tasks')
| -rw-r--r-- | test/tasks/email_test.exs | 52 | 
1 files changed, 52 insertions, 0 deletions
diff --git a/test/tasks/email_test.exs b/test/tasks/email_test.exs new file mode 100644 index 000000000..944c07064 --- /dev/null +++ b/test/tasks/email_test.exs @@ -0,0 +1,52 @@ +defmodule Mix.Tasks.Pleroma.EmailTest do +  use Pleroma.DataCase + +  import Swoosh.TestAssertions + +  alias Pleroma.Config +  alias Pleroma.Tests.ObanHelpers + +  setup_all do +    Mix.shell(Mix.Shell.Process) + +    on_exit(fn -> +      Mix.shell(Mix.Shell.IO) +    end) + +    :ok +  end + +  describe "pleroma.email test" do +    test "Sends test email with no given address" do +      mail_to = Config.get([:instance, :email]) + +      :ok = Mix.Tasks.Pleroma.Email.run(["test"]) + +      ObanHelpers.perform_all() + +      assert_receive {:mix_shell, :info, [message]} +      assert message =~ "Test email has been sent" + +      assert_email_sent( +        to: mail_to, +        html_body: ~r/a test email was requested./i +      ) +    end + +    test "Sends test email with given address" do +      mail_to = "hewwo@example.com" + +      :ok = Mix.Tasks.Pleroma.Email.run(["test", "--to", mail_to]) + +      ObanHelpers.perform_all() + +      assert_receive {:mix_shell, :info, [message]} +      assert message =~ "Test email has been sent" + +      assert_email_sent( +        to: mail_to, +        html_body: ~r/a test email was requested./i +      ) +    end +  end +end  | 
