Create pleroma.email mix task

Closes: https://git.pleroma.social/pleroma/pleroma/issues/1061
This commit is contained in:
Haelwenn (lanodan) Monnier 2020-01-20 13:23:21 +01:00
commit 4eb935be78
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
5 changed files with 116 additions and 0 deletions

52
test/tasks/email_test.exs Normal file
View file

@ -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