Skip to content

Commit 1f5370e

Browse files
committed
rabbitmq-cli: Deleting a non-existing user or vhost is fine
This patch adapts several testcases to this behavior change. The goal is to avoid transactions where there is no need for one.
1 parent 95f0d27 commit 1f5370e

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

deps/rabbitmq_cli/test/ctl/clear_permissions_command_test.exs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ defmodule ClearPermissionsTest do
5555
assert @command.validate(["too", "many"], %{}) == {:validation_failure, :too_many_args}
5656
end
5757

58-
@tag user: "fake_user"
59-
test "run: can't clear permissions for non-existing user", context do
60-
assert @command.run([context[:user]], context[:opts]) ==
61-
{:error, {:no_such_user, context[:user]}}
58+
@tag user: "fake_user", vhost: @default_vhost
59+
test "run: clearing permissions for non-existing user still succeeds", context do
60+
assert @command.run([context[:user]], context[:opts]) == :ok
6261
end
6362

6463
@tag user: @user, vhost: @default_vhost
@@ -85,9 +84,8 @@ defmodule ClearPermissionsTest do
8584
end
8685

8786
@tag user: @user, vhost: "bad_vhost"
88-
test "run: on an invalid vhost, return no_such_vhost error", context do
89-
assert @command.run([context[:user]], context[:opts]) ==
90-
{:error, {:no_such_vhost, context[:vhost]}}
87+
test "run: clearing permissions on a non-existent vhost still succeeds", context do
88+
assert @command.run([context[:user]], context[:opts]) == :ok
9189
end
9290

9391
@tag user: @user, vhost: @specific_vhost

deps/rabbitmq_cli/test/ctl/clear_topic_permissions_command_test.exs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,14 @@ defmodule ClearTopicPermissionsTest do
5858
{:validation_failure, :too_many_args}
5959
end
6060

61-
@tag user: "fake_user"
62-
test "run: can't clear topic permissions for non-existing user", context do
63-
assert @command.run([context[:user]], context[:opts]) ==
64-
{:error, {:no_such_user, context[:user]}}
61+
@tag user: "fake_user", vhost: @specific_vhost
62+
test "run: clearing topic permissions for non-existing user still succeeds", context do
63+
assert @command.run([context[:user]], context[:opts]) == :ok
6564
end
6665

6766
@tag user: @user, vhost: "bad_vhost"
68-
test "run: on an invalid vhost, return no_such_vhost error", context do
69-
assert @command.run([context[:user]], context[:opts]) ==
70-
{:error, {:no_such_vhost, context[:vhost]}}
67+
test "run: clearing topic permissions on an invalid vhost still succeeds", context do
68+
assert @command.run([context[:user]], context[:opts]) == :ok
7169
end
7270

7371
@tag user: @user, vhost: @specific_vhost

deps/rabbitmq_cli/test/ctl/delete_user_command_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ defmodule DeleteUserCommandTest do
4545
end
4646

4747
@tag user: @user
48-
test "run: An invalid username returns an error", context do
49-
assert @command.run(["no_one"], context[:opts]) == {:error, {:no_such_user, "no_one"}}
48+
test "run: deleting a non-existing user still succeeds", context do
49+
assert @command.run(["no_one"], context[:opts]) == :ok
5050
end
5151

5252
@tag user: @user

deps/rabbitmq_cli/test/rabbitmqctl_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ defmodule RabbitMQCtlTest do
164164
end
165165

166166
test "a command that fails with an error exits with a reasonable error code" do
167-
command = ["delete_user", "voldemort"]
168-
capture_io(:stderr, fn -> error_check(command, exit_nouser()) end)
167+
command = ["set_vhost_tags", "voldemort", "mytag"]
168+
capture_io(:stderr, fn -> error_check(command, exit_dataerr()) end)
169169
end
170170

171171
test "a mcommand with an unsupported option as the first command-line arg fails gracefully" do

0 commit comments

Comments
 (0)