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 | 3d1aa7e6204d5436c0c8a2c24172745f464e9964 (patch) | |
| tree | 6eed56c7681f46b3a60cc78a2c75ef05485af2ee /src | |
| parent | c3f8d28f324fa8df99253e12ed36f6225c27cfee (diff) | |
| download | rabbitmq-server-git-3d1aa7e6204d5436c0c8a2c24172745f464e9964.tar.gz | |
test for correct prepending of table headers
Diffstat (limited to 'src')
| -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 147e081e1a..2beb4c1889 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. |
