mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-08 17:34:19 +00:00
use assert_recieve
This commit is contained in:
parent
9f2bd3f944
commit
df573c898a
|
@ -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
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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 (?<total_count>\d+) uploads$", message)
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert_receive {:mix_shell, :info, [message]}
|
||||
|
||||
# @logevery in Mix.Tasks.Pleroma.Uploads
|
||||
count =
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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", %{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue