From d2490f9304a64f4509e8090e2ee80905f15ebfd0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 23 Aug 2023 08:23:03 +0200 Subject: [PATCH] test: fix user deletion CLI tests and bring back the -k option Signed-off-by: Thomas Citharel --- lib/mix/tasks/mobilizon/users/delete.ex | 11 ++++++++--- test/tasks/users_test.exs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/mix/tasks/mobilizon/users/delete.ex b/lib/mix/tasks/mobilizon/users/delete.ex index 73d1e4860..e6b9f20e1 100644 --- a/lib/mix/tasks/mobilizon/users/delete.ex +++ b/lib/mix/tasks/mobilizon/users/delete.ex @@ -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 diff --git a/test/tasks/users_test.exs b/test/tasks/users_test.exs index 22d455fbb..faf585b7d 100644 --- a/test/tasks/users_test.exs +++ b/test/tasks/users_test.exs @@ -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