aboutsummaryrefslogtreecommitdiff
path: root/test/tasks/email_test.exs
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-02-05 07:56:36 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-02-05 07:56:36 +0300
commite84fee5b8624c8909ddd8a7e0d99c6beea4f54d0 (patch)
treed0d2bfc3d847f9bb4fa03f08d9d60f49042b2688 /test/tasks/email_test.exs
parent86e4d23acb640efea8cbc879ddbeadfa0e04f9c8 (diff)
parenta56db789359c7c7d57b45e6c68f791eeadc171e4 (diff)
downloadpleroma-e84fee5b8624c8909ddd8a7e0d99c6beea4f54d0.tar.gz
Merge remote-tracking branch 'remotes/origin/develop' into 1505-threads-federation
Diffstat (limited to 'test/tasks/email_test.exs')
-rw-r--r--test/tasks/email_test.exs52
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