Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / test / tasks / email_test.exs
1 defmodule Mix.Tasks.Pleroma.EmailTest do
2 use Pleroma.DataCase
3
4 import Swoosh.TestAssertions
5
6 alias Pleroma.Config
7 alias Pleroma.Tests.ObanHelpers
8
9 setup_all do
10 Mix.shell(Mix.Shell.Process)
11
12 on_exit(fn ->
13 Mix.shell(Mix.Shell.IO)
14 end)
15
16 :ok
17 end
18
19 describe "pleroma.email test" do
20 test "Sends test email with no given address" do
21 mail_to = Config.get([:instance, :email])
22
23 :ok = Mix.Tasks.Pleroma.Email.run(["test"])
24
25 ObanHelpers.perform_all()
26
27 assert_receive {:mix_shell, :info, [message]}
28 assert message =~ "Test email has been sent"
29
30 assert_email_sent(
31 to: mail_to,
32 html_body: ~r/a test email was requested./i
33 )
34 end
35
36 test "Sends test email with given address" do
37 mail_to = "hewwo@example.com"
38
39 :ok = Mix.Tasks.Pleroma.Email.run(["test", "--to", mail_to])
40
41 ObanHelpers.perform_all()
42
43 assert_receive {:mix_shell, :info, [message]}
44 assert message =~ "Test email has been sent"
45
46 assert_email_sent(
47 to: mail_to,
48 html_body: ~r/a test email was requested./i
49 )
50 end
51 end
52 end