Update HTTP API tests
This relaxes assert_list/2 assertion to not require the size of an actually returned list element to be exactly equal to the size of the expected one. Sometimes it makes perfect sense to not assert on every single key but only a subset, and with this change, it now will be possible. Individual tests may choose to assert on all keys by listing them explicitly.
This commit is contained in:
parent
c41c27de06
commit
768b2f6925
|
|
@ -268,7 +268,10 @@ atomize_map_keys(I) ->
|
|||
|
||||
%% @todo There wasn't a specific order before; now there is; maybe we shouldn't have one?
|
||||
assert_list(Exp, Act) ->
|
||||
case length(Exp) == length(Act) of
|
||||
%% allow actual map to include keys we do not assert on
|
||||
%% but not the other way around: we may want to only assert on a subset
|
||||
%% of keys
|
||||
case length(Act) >= length(Exp) of
|
||||
true -> ok;
|
||||
false -> error({expected, Exp, actual, Act})
|
||||
end,
|
||||
|
|
|
|||
|
|
@ -1152,21 +1152,24 @@ queues_test(Config) ->
|
|||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{}},
|
||||
arguments => #{'x-queue-type' => <<"classic">>}
|
||||
},
|
||||
#{name => <<"foo">>,
|
||||
vhost => <<"downvhost">>,
|
||||
state => <<"stopped">>,
|
||||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{}}], DownQueues),
|
||||
arguments => #{'x-queue-type' => <<"classic">>}
|
||||
}], DownQueues),
|
||||
assert_item(#{name => <<"foo">>,
|
||||
vhost => <<"downvhost">>,
|
||||
state => <<"stopped">>,
|
||||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{}}, DownQueue),
|
||||
arguments => #{'x-queue-type' => <<"classic">>}
|
||||
}, DownQueue),
|
||||
|
||||
http_put(Config, "/queues/badvhost/bar", Good, ?NOT_FOUND),
|
||||
http_put(Config, "/queues/%2F/bar",
|
||||
|
|
@ -1188,21 +1191,21 @@ queues_test(Config) ->
|
|||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{},
|
||||
arguments => #{'x-queue-type' => <<"classic">>},
|
||||
storage_version => 2},
|
||||
#{name => <<"foo">>,
|
||||
vhost => <<"/">>,
|
||||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{},
|
||||
arguments => #{'x-queue-type' => <<"classic">>},
|
||||
storage_version => 2}], Queues),
|
||||
assert_item(#{name => <<"foo">>,
|
||||
vhost => <<"/">>,
|
||||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{},
|
||||
arguments => #{'x-queue-type' => <<"classic">>},
|
||||
storage_version => 2}, Queue),
|
||||
|
||||
http_delete(Config, "/queues/%2F/foo", {group, '2xx'}),
|
||||
|
|
@ -2242,7 +2245,8 @@ exclusive_queue_test(Config) ->
|
|||
durable => false,
|
||||
auto_delete => false,
|
||||
exclusive => true,
|
||||
arguments => #{}}, Queue),
|
||||
arguments => #{'x-queue-type' => <<"classic">>}
|
||||
}, Queue),
|
||||
true
|
||||
end),
|
||||
amqp_channel:close(Ch),
|
||||
|
|
@ -2809,7 +2813,7 @@ columns_test(Config) ->
|
|||
http_delete(Config, Path, [{group, '2xx'}, 404]),
|
||||
http_put(Config, Path, [{arguments, [{<<"x-message-ttl">>, TTL}]}],
|
||||
{group, '2xx'}),
|
||||
Item = #{arguments => #{'x-message-ttl' => TTL}, name => <<"columns.test">>},
|
||||
Item = #{arguments => #{'x-message-ttl' => TTL, 'x-queue-type' => <<"classic">>}, name => <<"columns.test">>},
|
||||
|
||||
?AWAIT(
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -381,21 +381,23 @@ queues_test(Config) ->
|
|||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{}},
|
||||
arguments => #{'x-queue-type' => <<"classic">>}
|
||||
},
|
||||
#{name => <<"foo">>,
|
||||
vhost => <<"downvhost">>,
|
||||
state => <<"stopped">>,
|
||||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{}}], DownQueues),
|
||||
arguments => #{'x-queue-type' => <<"classic">>}
|
||||
}], DownQueues),
|
||||
assert_item(#{name => <<"foo">>,
|
||||
vhost => <<"downvhost">>,
|
||||
state => <<"stopped">>,
|
||||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{}}, DownQueue),
|
||||
arguments => #{'x-queue-type' => <<"classic">>}}, DownQueue),
|
||||
|
||||
http_put(Config, "/queues/badvhost/bar", Good, ?NOT_FOUND),
|
||||
http_put(Config, "/queues/%2F/bar",
|
||||
|
|
@ -418,7 +420,7 @@ queues_test(Config) ->
|
|||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{},
|
||||
arguments => #{'x-queue-type' => <<"classic">>},
|
||||
node => NodeBin},
|
||||
#{name => <<"foo">>,
|
||||
vhost => <<"/">>,
|
||||
|
|
@ -495,7 +497,7 @@ queues_enable_totals_test(Config) ->
|
|||
durable => true,
|
||||
auto_delete => false,
|
||||
exclusive => false,
|
||||
arguments => #{},
|
||||
arguments => #{'x-queue-type' => <<"classic">>},
|
||||
node => NodeBin,
|
||||
messages => 1,
|
||||
messages_ready => 1,
|
||||
|
|
@ -882,7 +884,8 @@ exclusive_queue_test(Config) ->
|
|||
durable => false,
|
||||
auto_delete => false,
|
||||
exclusive => true,
|
||||
arguments => #{}}, Queue),
|
||||
arguments => #{'x-queue-type' => <<"classic">>}
|
||||
}, Queue),
|
||||
amqp_channel:close(Ch),
|
||||
close_connection(Conn),
|
||||
passed.
|
||||
|
|
@ -1514,7 +1517,7 @@ columns_test(Config) ->
|
|||
http_delete(Config, Path, [{group, '2xx'}, 404]),
|
||||
http_put(Config, Path, [{arguments, [{<<"x-message-ttl">>, TTL}]}],
|
||||
{group, '2xx'}),
|
||||
Item = #{arguments => #{'x-message-ttl' => TTL}, name => <<"columns.test">>},
|
||||
Item = #{arguments => #{'x-message-ttl' => TTL, 'x-queue-type' => <<"classic">>}, name => <<"columns.test">>},
|
||||
timer:sleep(2000),
|
||||
[Item] = http_get(Config, "/queues?columns=arguments.x-message-ttl,name", ?OK),
|
||||
Item = http_get(Config, "/queues/%2F/columns.test?columns=arguments.x-message-ttl,name", ?OK),
|
||||
|
|
|
|||
Loading…
Reference in New Issue