Most of my code looks like this
handle_event({publish,Publish_Msg,Publishing_Channel},State)->
Member = pg2:get_members(helpers:get_channel_name(Publishing_Channel)),
case Member of
[M|O]->
[Pid!{send,Publish_Msg}||Pid<-[M|O]];
{error,_}-> lager:info("unavailable")
end,
{ok,State};
The above handler gets called for publish event and all it does is it sends a message to a process id.
What I would like to do is create a bunch of mock Pids and and then have this event handler send data to those. And check if the data is actually received by them. Is there any way to do this with EUNIT. Or is there a better way to test event handlers?