diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2011-06-26 16:38:51 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2011-06-26 16:38:51 +0100 |
commit | 8b5c2df689442652288bbfd865554e8f4f384f58 (patch) | |
tree | beba605f547d32460b1a8b3b9ba5f571f5873103 | |
parent | 78b92f44d5ce7b6715d48b27bf6b38749023eba3 (diff) | |
download | rabbitmq-server-8b5c2df689442652288bbfd865554e8f4f384f58.tar.gz |
Refactoring
-rw-r--r-- | src/rabbit_tests.erl | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 624d41fb..c6f88980 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -2087,8 +2087,11 @@ variable_queue_init(Q, Recover) -> Q, Recover, fun nop/2, fun nop/2, fun nop/2, fun nop/1). variable_queue_publish(IsPersistent, Count, VQ) -> + variable_queue_publish(IsPersistent, Count, fun (_N, P) -> P end, VQ). + +variable_queue_publish(IsPersistent, Count, PropFun, VQ) -> lists:foldl( - fun (_N, VQN) -> + fun (N, VQN) -> rabbit_variable_queue:publish( rabbit_basic:message( rabbit_misc:r(<<>>, exchange, <<>>), @@ -2096,7 +2099,7 @@ variable_queue_publish(IsPersistent, Count, VQ) -> true -> 2; false -> 1 end}, <<>>), - #message_properties{}, self(), VQN) + PropFun(N, #message_properties{}), self(), VQN) end, VQ, lists:seq(1, Count)). variable_queue_fetch(Count, IsPersistent, IsDelivered, Len, VQ) -> @@ -2173,14 +2176,9 @@ test_dropwhile(VQ0) -> Count = 10, %% add messages with sequential expiry - VQ1 = lists:foldl( - fun (N, VQN) -> - rabbit_variable_queue:publish( - rabbit_basic:message( - rabbit_misc:r(<<>>, exchange, <<>>), - <<>>, #'P_basic'{}, <<>>), - #message_properties{expiry = N}, self(), VQN) - end, VQ0, lists:seq(1, Count)), + VQ1 = variable_queue_publish( + false, Count, + fun (N, Props) -> Props#message_properties{expiry = N} end, VQ0), %% drop the first 5 messages VQ2 = rabbit_variable_queue:dropwhile( @@ -2201,18 +2199,10 @@ test_dropwhile(VQ0) -> VQ4. test_dropwhile_varying_ram_duration(VQ0) -> - VQ1 = rabbit_variable_queue:publish( - rabbit_basic:message( - rabbit_misc:r(<<>>, exchange, <<>>), - <<>>, #'P_basic'{}, <<>>), - #message_properties{}, self(), VQ0), + VQ1 = variable_queue_publish(false, 1, VQ0), VQ2 = rabbit_variable_queue:set_ram_duration_target(0, VQ1), VQ3 = rabbit_variable_queue:set_ram_duration_target(infinity, VQ2), - VQ4 = rabbit_variable_queue:publish( - rabbit_basic:message( - rabbit_misc:r(<<>>, exchange, <<>>), - <<>>, #'P_basic'{}, <<>>), - #message_properties{}, self(), VQ3), + VQ4 = variable_queue_publish(false, 1, VQ3), rabbit_variable_queue:dropwhile(fun(_) -> false end, VQ4). test_variable_queue_dynamic_duration_change(VQ0) -> |