Skip to content

Commit 78e8c59

Browse files
committed
set_permissions_globally_command_test: Fix "invalid_regex patterns" test expectations
Testcases are executed in a random order. Unfortunately, this testcase depended on side effects of other testcases. If this testcase was executed first, then there were no permissions set and the testcase would fail. It now lists permissions before and after the actual test and compare both.
1 parent 271a7ba commit 78e8c59

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

deps/rabbitmq_cli/test/ctl/set_permissions_globally_command_test.exs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,23 @@ defmodule SetPermissionsGloballyCommandTest do
9393

9494
@tag user: @user
9595
test "run: invalid regex patterns returns an error", context do
96+
p1 = Enum.find(list_permissions(@vhost1), fn x -> x[:user] == context[:user] end)
97+
p2 = Enum.find(list_permissions(@vhost2), fn x -> x[:user] == context[:user] end)
98+
p3 = Enum.find(list_permissions(@vhost3), fn x -> x[:user] == context[:user] end)
99+
96100
assert @command.run(
97101
[context[:user], "^#{context[:user]}-.*", ".*", "*"],
98102
context[:opts]
99103
) == {:error, {:invalid_regexp, '*', {'nothing to repeat', 0}}}
100104

101105
# asserts that the failed command didn't change anything
102-
p1 = Enum.find(list_permissions(@vhost1), fn x -> x[:user] == context[:user] end)
103-
p2 = Enum.find(list_permissions(@vhost2), fn x -> x[:user] == context[:user] end)
104-
p3 = Enum.find(list_permissions(@vhost3), fn x -> x[:user] == context[:user] end)
106+
p4 = Enum.find(list_permissions(@vhost1), fn x -> x[:user] == context[:user] end)
107+
p5 = Enum.find(list_permissions(@vhost2), fn x -> x[:user] == context[:user] end)
108+
p6 = Enum.find(list_permissions(@vhost3), fn x -> x[:user] == context[:user] end)
105109

106-
assert p1 == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
107-
assert p2 == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
108-
assert p3 == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
110+
assert p1 == p4
111+
assert p2 == p5
112+
assert p3 == p6
109113
end
110114

111115
@tag user: @user

0 commit comments

Comments
 (0)