From df573c898ac32d822b31bcd2285b10e1a4f978d4 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Wed, 2 Aug 2023 18:02:47 +0100 Subject: [PATCH] use assert_recieve --- test/mix/pleroma_test.exs | 4 +- test/mix/tasks/pleroma/config_test.exs | 2 +- test/mix/tasks/pleroma/uploads_test.exs | 6 +- test/mix/tasks/pleroma/user_test.exs | 88 +++++++++---------- test/pleroma/web/federator_test.exs | 2 +- .../web/o_auth/ldap_authorization_test.exs | 6 +- .../cron/digest_emails_worker_test.exs | 2 +- .../cron/new_users_digest_worker_test.exs | 2 +- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/test/mix/pleroma_test.exs b/test/mix/pleroma_test.exs index af62cc1d9..dfc457080 100644 --- a/test/mix/pleroma_test.exs +++ b/test/mix/pleroma_test.exs @@ -21,7 +21,7 @@ defmodule Mix.PleromaTest do send(self(), {:mix_shell_input, :prompt, "Yes"}) answer = shell_prompt("Do you want this?") - assert_received {:mix_shell, :prompt, [message]} + assert_receive {:mix_shell, :prompt, [message]} assert message =~ "Do you want this?" assert answer == "Yes" end @@ -31,7 +31,7 @@ defmodule Mix.PleromaTest do answer = shell_prompt("Do you want this?", "defval") - assert_received {:mix_shell, :prompt, [message]} + assert_receive {:mix_shell, :prompt, [message]} assert message =~ "Do you want this? [defval]" assert answer == "defval" end diff --git a/test/mix/tasks/pleroma/config_test.exs b/test/mix/tasks/pleroma/config_test.exs index 15ffe0ce6..46c109cc1 100644 --- a/test/mix/tasks/pleroma/config_test.exs +++ b/test/mix/tasks/pleroma/config_test.exs @@ -58,7 +58,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do MixTask.migrate_to_db("test/fixtures/config/temp.secret.exs") - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "Migration is not allowed until all deprecation warnings have been resolved." diff --git a/test/mix/tasks/pleroma/uploads_test.exs b/test/mix/tasks/pleroma/uploads_test.exs index a7d15e0fa..d2e4d85a9 100644 --- a/test/mix/tasks/pleroma/uploads_test.exs +++ b/test/mix/tasks/pleroma/uploads_test.exs @@ -24,15 +24,15 @@ defmodule Mix.Tasks.Pleroma.UploadsTest do store: fn %Upload{name: _file, path: _path}, _opts -> {:ok, %{}} end do Mix.Tasks.Pleroma.Uploads.run(["migrate_local", "S3"]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "Migrating files from local" - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert %{"total_count" => total_count} = Regex.named_captures(~r"^Found (?\d+) uploads$", message) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} # @logevery in Mix.Tasks.Pleroma.Uploads count = diff --git a/test/mix/tasks/pleroma/user_test.exs b/test/mix/tasks/pleroma/user_test.exs index a2178bbd1..906e8a5d3 100644 --- a/test/mix/tasks/pleroma/user_test.exs +++ b/test/mix/tasks/pleroma/user_test.exs @@ -52,13 +52,13 @@ defmodule Mix.Tasks.Pleroma.UserTest do "--admin" ]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "user will be created" - assert_received {:mix_shell, :prompt, [message]} + assert_receive {:mix_shell, :prompt, [message]} assert message =~ "Continue" - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "created" user = User.get_cached_by_nickname(unsaved.nickname) @@ -77,13 +77,13 @@ defmodule Mix.Tasks.Pleroma.UserTest do Mix.Tasks.Pleroma.User.run(["new", unsaved.nickname, unsaved.email]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "user will be created" - assert_received {:mix_shell, :prompt, [message]} + assert_receive {:mix_shell, :prompt, [message]} assert message =~ "Continue" - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "will not be created" refute User.get_cached_by_nickname(unsaved.nickname) @@ -100,7 +100,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do Mix.Tasks.Pleroma.User.run(["rm", user.nickname]) ObanHelpers.perform_all() - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ " deleted" assert %{is_active: false} = User.get_by_nickname(user.nickname) @@ -138,7 +138,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do Mix.Tasks.Pleroma.User.run(["rm", user.nickname]) ObanHelpers.perform_all() - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ " deleted" assert %{is_active: false} = User.get_by_nickname(user.nickname) @@ -152,7 +152,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "no user to delete" do Mix.Tasks.Pleroma.User.run(["rm", "nonexistent"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No local user" end end @@ -169,7 +169,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do Mix.Tasks.Pleroma.User.run(["deactivate", user.nickname]) # Note that the task has delay :timer.sleep(500) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "Successfully deactivated #{user.nickname} and unsubscribed all local followers" @@ -183,7 +183,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do %{id: id, nickname: nickname} = insert(:user, is_active: false) assert :ok = Mix.Tasks.Pleroma.User.run(["deactivate", nickname]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "User #{nickname} already deactivated" user = Repo.get(User, id) @@ -193,7 +193,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "no user to deactivate" do Mix.Tasks.Pleroma.User.run(["deactivate", "nonexistent"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No user" end end @@ -211,16 +211,16 @@ defmodule Mix.Tasks.Pleroma.UserTest do "--moderator" ]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Admin status .* true/ - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Confirmation status.* true/ - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Locked status .* true/ - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Moderator status .* true/ user = User.get_cached_by_nickname(user.nickname) @@ -248,16 +248,16 @@ defmodule Mix.Tasks.Pleroma.UserTest do "--no-moderator" ]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Admin status .* false/ - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Confirmation status.* false/ - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Locked status .* false/ - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ ~r/Moderator status .* false/ user = User.get_cached_by_nickname(user.nickname) @@ -270,7 +270,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "no user to set status" do Mix.Tasks.Pleroma.User.run(["set", "nonexistent", "--moderator"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No local user" end end @@ -283,14 +283,14 @@ defmodule Mix.Tasks.Pleroma.UserTest do Mix.Tasks.Pleroma.User.run(["reset_password", user.nickname]) end) =~ "URL:" - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "Generated" end test "no user to reset password" do Mix.Tasks.Pleroma.User.run(["reset_password", "nonexistent"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No local user" end end @@ -307,7 +307,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do Mix.Tasks.Pleroma.User.run(["reset_mfa", user.nickname]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "Multi-Factor Authentication disabled for #{user.nickname}" assert %{enabled: false, totp: false} == @@ -319,7 +319,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "no user to reset MFA" do Mix.Tasks.Pleroma.User.run(["reset_password", "nonexistent"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No local user" end end @@ -330,7 +330,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do Mix.Tasks.Pleroma.User.run(["invite"]) end) =~ "http" - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "Generated user invite token one time" end @@ -343,7 +343,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do ]) end) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "Generated user invite token date limited" end @@ -356,7 +356,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do ]) end) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "Generated user invite token reusable" end @@ -371,7 +371,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do ]) end) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "Generated user invite token reusable date limited" end end @@ -390,9 +390,9 @@ defmodule Mix.Tasks.Pleroma.UserTest do # end) - assert_received {:mix_shell, :info, [message]} - assert_received {:mix_shell, :info, [message2]} - assert_received {:mix_shell, :info, [message3]} + assert_receive {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message2]} + assert_receive {:mix_shell, :info, [message3]} assert message =~ "Invites list:" assert message2 =~ invite.invite_type assert message3 =~ invite2.invite_type @@ -410,7 +410,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do ]) end) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message =~ "Invite for token #{invite.token} was revoked." end end @@ -420,14 +420,14 @@ defmodule Mix.Tasks.Pleroma.UserTest do %{nickname: nickname} = insert(:user) assert :ok == Mix.Tasks.Pleroma.User.run(["delete_activities", nickname]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "User #{nickname} statuses deleted." end test "it prints an error message when user is not exist" do Mix.Tasks.Pleroma.User.run(["delete_activities", "foo"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No local user" end end @@ -437,7 +437,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do %{id: id, nickname: nickname} = insert(:user, is_confirmed: true) assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "#{nickname} doesn't need confirmation." user = Repo.get(User, id) @@ -450,7 +450,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do insert(:user, is_confirmed: false, confirmation_token: "some token") assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "#{nickname} doesn't need confirmation." user = Repo.get(User, id) @@ -461,7 +461,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "it prints an error message when user is not exist" do Mix.Tasks.Pleroma.User.run(["confirm", "foo"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No local user" end end @@ -471,7 +471,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do %{id: id, nickname: nickname} = insert(:user, is_active: true) assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "User #{nickname} already activated" user = Repo.get(User, id) @@ -482,7 +482,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do %{id: id, nickname: nickname} = insert(:user, is_active: false) assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname]) - assert_received {:mix_shell, :info, [message]} + assert_receive {:mix_shell, :info, [message]} assert message == "Successfully activated #{nickname}" user = Repo.get(User, id) @@ -492,7 +492,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "no user to activate" do Mix.Tasks.Pleroma.User.run(["activate", "foo"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No user" end end @@ -536,7 +536,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "it prints an error message when user is not exist" do Mix.Tasks.Pleroma.User.run(["sign_out", "foo"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "No local user" end end @@ -554,7 +554,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "it prints an error message when user is not exist" do Mix.Tasks.Pleroma.User.run(["tag", "foo"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "Could not change user tags" end end @@ -573,7 +573,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do test "it prints an error message when user is not exist" do Mix.Tasks.Pleroma.User.run(["untag", "foo"]) - assert_received {:mix_shell, :error, [message]} + assert_receive {:mix_shell, :error, [message]} assert message =~ "Could not change user tags" end end diff --git a/test/pleroma/web/federator_test.exs b/test/pleroma/web/federator_test.exs index c774090d5..25386db41 100644 --- a/test/pleroma/web/federator_test.exs +++ b/test/pleroma/web/federator_test.exs @@ -49,7 +49,7 @@ defmodule Pleroma.Web.FederatorTest do ObanHelpers.perform(all_enqueued(worker: PublisherWorker)) end - assert_received :relay_publish + assert_receive :relay_publish end test "with relays deactivated, it does not publish to the relay", %{ diff --git a/test/pleroma/web/o_auth/ldap_authorization_test.exs b/test/pleroma/web/o_auth/ldap_authorization_test.exs index 4ea9c9f73..5df29b154 100644 --- a/test/pleroma/web/o_auth/ldap_authorization_test.exs +++ b/test/pleroma/web/o_auth/ldap_authorization_test.exs @@ -50,7 +50,7 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do token = Repo.get_by(Token, token: token) assert token.user_id == user.id - assert_received :close_connection + assert_receive :close_connection end end @@ -94,7 +94,7 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do token = Repo.get_by(Token, token: token) |> Repo.preload(:user) assert token.user.nickname == user.nickname - assert_received :close_connection + assert_receive :close_connection end end @@ -129,7 +129,7 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do }) assert %{"error" => "Invalid credentials"} = json_response(conn, 400) - assert_received :close_connection + assert_receive :close_connection end end end diff --git a/test/pleroma/workers/cron/digest_emails_worker_test.exs b/test/pleroma/workers/cron/digest_emails_worker_test.exs index b3ca6235b..461622440 100644 --- a/test/pleroma/workers/cron/digest_emails_worker_test.exs +++ b/test/pleroma/workers/cron/digest_emails_worker_test.exs @@ -39,7 +39,7 @@ defmodule Pleroma.Workers.Cron.DigestEmailsWorkerTest do # Performing job(s) enqueued at previous step ObanHelpers.perform_all() - assert_received {:email, email} + assert_receive {:email, email} assert email.to == [{user2.name, user2.email}] assert email.subject == "Your digest from #{Pleroma.Config.get(:instance)[:name]}" end diff --git a/test/pleroma/workers/cron/new_users_digest_worker_test.exs b/test/pleroma/workers/cron/new_users_digest_worker_test.exs index f9ef265c2..8a2d7b316 100644 --- a/test/pleroma/workers/cron/new_users_digest_worker_test.exs +++ b/test/pleroma/workers/cron/new_users_digest_worker_test.exs @@ -20,7 +20,7 @@ defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do NewUsersDigestWorker.perform(%Oban.Job{}) ObanHelpers.perform_all() - assert_received {:email, email} + assert_receive {:email, email} assert email.to == [{admin.name, admin.email}] assert email.subject == "#{Pleroma.Config.get([:instance, :name])} New Users"