Adopt tests to the new rabbit_vhost_limits:list API
This commit is contained in:
parent
0a8b2d9604
commit
cea4e1803c
|
|
@ -83,14 +83,14 @@ defmodule ClearVhostLimitsCommandTest do
|
|||
|
||||
:ok = set_vhost_limits(context[:vhost], @definition)
|
||||
|
||||
assert get_vhost_limits(context[:vhost]) != %{}
|
||||
assert get_vhost_limits(context[:vhost]) != []
|
||||
|
||||
assert @command.run(
|
||||
[],
|
||||
vhost_opts
|
||||
) == :ok
|
||||
|
||||
assert get_vhost_limits(context[:vhost]) == %{}
|
||||
assert get_vhost_limits(context[:vhost]) == []
|
||||
end
|
||||
|
||||
@tag vhost: "bad-vhost"
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ defmodule SetVhostLimitsCommandTest do
|
|||
context[:opts]
|
||||
) == {:error_string, 'JSON decoding error'}
|
||||
|
||||
assert get_vhost_limits(context[:vhost]) == %{}
|
||||
assert get_vhost_limits(context[:vhost]) == []
|
||||
end
|
||||
|
||||
test "run: invalid limit returns an error", context do
|
||||
|
|
@ -121,7 +121,7 @@ defmodule SetVhostLimitsCommandTest do
|
|||
context[:opts]
|
||||
) == {:error_string, 'Validation failed\n\nUnrecognised terms [{<<"foo">>,<<"bar">>}] in limits\n'}
|
||||
|
||||
assert get_vhost_limits(context[:vhost]) == %{}
|
||||
assert get_vhost_limits(context[:vhost]) == []
|
||||
end
|
||||
|
||||
test "run: an empty JSON object definition unsets all limits for vhost", context do
|
||||
|
|
@ -138,7 +138,7 @@ defmodule SetVhostLimitsCommandTest do
|
|||
context[:opts]
|
||||
) == :ok
|
||||
|
||||
assert get_vhost_limits(context[:vhost]) == %{}
|
||||
assert get_vhost_limits(context[:vhost]) == [{"test1", %{}}]
|
||||
end
|
||||
|
||||
test "banner", context do
|
||||
|
|
@ -149,7 +149,8 @@ defmodule SetVhostLimitsCommandTest do
|
|||
end
|
||||
|
||||
defp assert_limits(context) do
|
||||
limits = get_vhost_limits(context[:vhost])
|
||||
vhost = context[:vhost]
|
||||
[{vhost, limits}] = get_vhost_limits(context[:vhost])
|
||||
assert {:ok, limits} == JSON.decode(context[:definition])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ defmodule TestHelper do
|
|||
end
|
||||
def get_vhost_limits(vhost) do
|
||||
:rpc.call(get_rabbit_hostname, :rabbit_vhost_limit, :list, [vhost])
|
||||
|> Map.new
|
||||
|> Enum.map(fn({vhost, limits}) -> {vhost, Map.new(limits)} end)
|
||||
end
|
||||
|
||||
def clear_vhost_limits(vhost) do
|
||||
|
|
|
|||
Loading…
Reference in New Issue