Adopt tests to the new rabbit_vhost_limits:list API

This commit is contained in:
Daniil Fedotov 2017-01-16 12:09:10 +00:00
parent 0a8b2d9604
commit cea4e1803c
3 changed files with 8 additions and 7 deletions

View File

@ -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"

View File

@ -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

View File

@ -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