Permalink
Browse files

separate clients for pub/sub, cosmetics

  • Loading branch information...
1 parent c079db2 commit b20bf08ee057f8ec8a94701f8eee9104d9868ae5 @mabrek committed Feb 22, 2011
Showing with 15 additions and 7 deletions.
  1. +15 −7 test/rabbit_redis_test.erl
View
@@ -1,16 +1,24 @@
-module(rabbit_redis_test).
-export([test/0]).
+-define(REDIS_HOST, "localhost").
+-define(REDIS_PORT, 6379).
+
test() ->
+ start_stop(),
+ redis_only_pubsub().
+
+start_stop() ->
ok = application:start(rabbit_redis),
- ok = application:stop(rabbit_redis),
-
- {ok, RedisPublisher} = erldis:connect(),
- Redis = erldis_sup:client(),
- RedisChannel = <<"channel">>,
+ ok = application:stop(rabbit_redis).
+
+redis_only_pubsub() ->
+ {ok, Publisher} = erldis_client:start_link(?REDIS_HOST, ?REDIS_PORT),
+ {ok, Subscriber} = erldis_client:start_link(?REDIS_HOST, ?REDIS_PORT),
+ Channel = <<"channel">>,
Payload = <<"payload">>,
- erldis:subscribe(Redis, RedisChannel, self()),
- 1 = erldis:publish(RedisPublisher, RedisChannel, Payload),
+ erldis:subscribe(Subscriber, Channel, self()),
+ 1 = erldis:publish(Publisher, Channel, Payload),
receive
{message, Channel, Payload} ->
ok;

0 comments on commit b20bf08

Please sign in to comment.