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

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-08-23 08:23:03 +02:00
parent 860b4eb9a3
commit d2490f9304
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
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