Skip to content

Commit

Permalink
patch bunnyc to survive a restart like gen_bunny can
Browse files Browse the repository at this point in the history
  • Loading branch information
boorad committed Nov 18, 2010
1 parent 0def22e commit af251d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bunnyc.erl
Expand Up @@ -135,6 +135,9 @@ handle_cast(_Request, State) ->
{noreply, State}.


handle_info({reconnected, {ConnectionPid, ChannelPid}}, State) ->
{noreply, State#bunnyc_state{connection=ConnectionPid, channel=ChannelPid}};

handle_info(_Info, State) ->
{noreply, State}.

Expand Down
10 changes: 10 additions & 0 deletions test/bunnyc_tests.erl
Expand Up @@ -251,6 +251,16 @@ unknown_cast_test() ->
bunnyc:handle_cast(unknown_cast, #bunnyc_state{})).


reconnected_info_test() ->
ConnectionPid = a,
ChannelPid = b,
{noreply, #bunnyc_state{connection=Conn, channel=Chan}} =
bunnyc:handle_info({reconnected, {ConnectionPid, ChannelPid}},
#bunnyc_state{}),
?assertEqual(Conn, ConnectionPid),
?assertEqual(Chan, ChannelPid).


unknown_info_test() ->
?assertEqual({noreply, #bunnyc_state{}},
bunnyc:handle_info(unknown_info, #bunnyc_state{})).
Expand Down

0 comments on commit af251d2

Please sign in to comment.