blob: c3af7ef68ab3a2c7dc9b91844257660f59795789 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
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
setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
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
|