diff options
author | Tim Watson <tim@rabbitmq.com> | 2012-10-25 13:21:54 +0100 |
---|---|---|
committer | Tim Watson <tim@rabbitmq.com> | 2012-10-25 13:21:54 +0100 |
commit | 80783857100b8353a42a38a5504da112475c9b8c (patch) | |
tree | 6eed56c7681f46b3a60cc78a2c75ef05485af2ee | |
parent | 0ea5176dbbe182cac2c1b6fd6fe751a79c72af87 (diff) | |
download | rabbitmq-server-80783857100b8353a42a38a5504da112475c9b8c.tar.gz |
test for correct prepending of table headers
-rw-r--r-- | src/rabbit_basic_tests.erl | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/rabbit_basic_tests.erl b/src/rabbit_basic_tests.erl index 147e081e..2beb4c18 100644 --- a/src/rabbit_basic_tests.erl +++ b/src/rabbit_basic_tests.erl @@ -26,11 +26,30 @@ {<<"exchange">>, longstr, <<"my-exchange">>}, {<<"routing-keys">>, array, []}]). -write_table_with_invalid_existing_type_test() -> - assertInvalid(<<"x-death">>, {longstr, <<"this should be a table!!!">>}, - ?XDEATH_TABLE). +-define(ROUTE_TABLE, [{<<"redelivered">>, bool, <<"true">>}]). -assertInvalid(HeaderKey, {TBin, VBin}=InvalidEntry, HeaderTable) -> +write_table_with_invalid_existing_type_test_() -> + [{"existing entries with invalid types are moved to a table " + "stored as <<\"x-invalid-headers header\">>", + assert_invalid(<<"x-death">>, + {longstr, <<"this should be a table!!!">>}, + ?XDEATH_TABLE)}, + {"if invalid existing headers are moved, newly added " + "ones are still stored correctly", + begin + BadHeaders = [{<<"x-received-from">>, + longstr, <<"this should be a table!!!">>}], + Headers = rabbit_basic:append_table_header( + <<"x-received-from">>, ?ROUTE_TABLE, BadHeaders), + ?_assertEqual({array, [{table, ?ROUTE_TABLE}]}, + rabbit_misc:table_lookup(Headers, <<"x-received-from">>)) + end} + ]. + +assert_invalid(HeaderKey, Entry, Table) -> + fun() -> check_invalid(HeaderKey, Entry, Table) end. + +check_invalid(HeaderKey, {TBin, VBin}=InvalidEntry, HeaderTable) -> Headers = rabbit_basic:append_table_header(HeaderKey, HeaderTable, [{HeaderKey, TBin, VBin}]), InvalidHeaders = rabbit_misc:table_lookup(Headers, ?INVALID_HEADERS_KEY), @@ -39,5 +58,6 @@ assertInvalid(HeaderKey, {TBin, VBin}=InvalidEntry, HeaderTable) -> InvalidArrayForKey = rabbit_misc:table_lookup(Invalid, HeaderKey), ?assertMatch({array, _}, InvalidArrayForKey), {_, Array} = InvalidArrayForKey, - ?assertMatch([InvalidEntry], Array). + ?assertMatch([InvalidEntry], Array), + Headers. |