Merge branch 'fix-user-clitests' into 'main'

test: fix user deletion CLI tests and bring back the -k option

See merge request framasoft/mobilizon!1438
This commit is contained in:
Thomas Citharel 2023-08-23 06:26:13 +00:00
commit 7cc4abd47b
2 changed files with 9 additions and 4 deletions

View File

@ -21,11 +21,13 @@ defmodule Mix.Tasks.Mobilizon.Users.Delete do
all_matching_email_domain: :boolean,
all_matching_ip: :boolean,
include_groups_where_admin: :boolean,
keep_email: :boolean,
help: :boolean
],
aliases: [
y: :assume_yes,
h: :help
h: :help,
k: :keep_email,
y: :assume_yes
]
)
@ -156,7 +158,7 @@ defmodule Mix.Tasks.Mobilizon.Users.Delete do
Delete.delete(actor, actor, true)
end) do
# Delete user
Users.delete_user(user, reserve_email: false)
Users.delete_user(user, reserve_email: Keyword.get(options, :keep_email, false))
end
end
@ -191,6 +193,9 @@ defmodule Mix.Tasks.Mobilizon.Users.Delete do
--all-matching-ip
Delete all users matching the given input as email domain
-k/--keep-email
Keep a record of the email in the users table so that the email can't be used to register again
-h/--help
Show the help

View File

@ -204,7 +204,7 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do
test "delete non-existing user" do
Delete.run([@email, "-y"])
assert_received {:mix_shell, :error, [message]}
assert message =~ "Error: No such user"
assert message == "No user with the email \"#{@email}\" was found"
end
end