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.
This commit is contained in:
parent
271a7babdf
commit
78e8c595b1
|
|
@ -93,19 +93,23 @@ defmodule SetPermissionsGloballyCommandTest do
|
|||
|
||||
@tag user: @user
|
||||
test "run: invalid regex patterns returns an error", context do
|
||||
p1 = Enum.find(list_permissions(@vhost1), fn x -> x[:user] == context[:user] end)
|
||||
p2 = Enum.find(list_permissions(@vhost2), fn x -> x[:user] == context[:user] end)
|
||||
p3 = Enum.find(list_permissions(@vhost3), fn x -> x[:user] == context[:user] end)
|
||||
|
||||
assert @command.run(
|
||||
[context[:user], "^#{context[:user]}-.*", ".*", "*"],
|
||||
context[:opts]
|
||||
) == {:error, {:invalid_regexp, '*', {'nothing to repeat', 0}}}
|
||||
|
||||
# asserts that the failed command didn't change anything
|
||||
p1 = Enum.find(list_permissions(@vhost1), fn x -> x[:user] == context[:user] end)
|
||||
p2 = Enum.find(list_permissions(@vhost2), fn x -> x[:user] == context[:user] end)
|
||||
p3 = Enum.find(list_permissions(@vhost3), fn x -> x[:user] == context[:user] end)
|
||||
p4 = Enum.find(list_permissions(@vhost1), fn x -> x[:user] == context[:user] end)
|
||||
p5 = Enum.find(list_permissions(@vhost2), fn x -> x[:user] == context[:user] end)
|
||||
p6 = Enum.find(list_permissions(@vhost3), fn x -> x[:user] == context[:user] end)
|
||||
|
||||
assert p1 == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
|
||||
assert p2 == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
|
||||
assert p3 == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
|
||||
assert p1 == p4
|
||||
assert p2 == p5
|
||||
assert p3 == p6
|
||||
end
|
||||
|
||||
@tag user: @user
|
||||
|
|
|
|||
Loading…
Reference in New Issue