diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-02-11 13:54:55 +0400 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-02-11 13:54:55 +0400 |
commit | 6875ccb6bfcc5ae62db26d38c3d5eac4c6f8706a (patch) | |
tree | dacb02d953473e3a0c6aeec58d86fb7fb1ed5886 /test/tasks/email_test.exs | |
parent | 3c4a30c6db312aff2afbfcd423498be19c02c68c (diff) | |
parent | 5ebffd5224729413e53a55ddda9a1f86224d7d73 (diff) | |
download | pleroma-6875ccb6bfcc5ae62db26d38c3d5eac4c6f8706a.tar.gz pleroma-6875ccb6bfcc5ae62db26d38c3d5eac4c6f8706a.zip |
Merge branch 'develop' into feature/new-registrations-digest
Diffstat (limited to 'test/tasks/email_test.exs')
-rw-r--r-- | test/tasks/email_test.exs | 52 |
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 |