aboutsummaryrefslogtreecommitdiff
path: root/test/tasks
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-01-20 13:23:21 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-01-28 16:49:38 +0100
commit4eb935be78eeaf1decb7fc109cec09ca18d82854 (patch)
tree4be2d8c3c0edce50783de984123c6a563affb018 /test/tasks
parentb12f3064730648de992f934cf5a23cadb5206b9d (diff)
downloadpleroma-4eb935be78eeaf1decb7fc109cec09ca18d82854.tar.gz
Create pleroma.email mix task
Closes: https://git.pleroma.social/pleroma/pleroma/issues/1061
Diffstat (limited to 'test/tasks')
-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