Permalink
Browse files

more unit tests

  • Loading branch information...
1 parent 3cdbbb5 commit 0ba9b2816d0a1dca123d5b43562a33345cfc580f @ckruse committed Apr 20, 2012
Showing with 32 additions and 3 deletions.
  1. +9 −0 test/irc_controller_test.erl
  2. +2 −2 test/irckerl_channel_test.erl
  3. +21 −1 test/irckerl_controller_test.erl
@@ -106,6 +106,15 @@ join_test() ->
5000 ->
throw({error, receive_timeout})
end,
+ receive
+ {'$gen_event', {join,"cjk101010_!ckruse@localhost","#selfhtml"}} ->
+ ok;
+ Dt1 ->
+ throw({error, received_message_does_not_match, Dt1})
+ after
+ 5000 ->
+ throw({error, receive_timeout})
+ end,
?assertMatch(
true,
@@ -81,8 +81,8 @@ join_part_test() ->
receive
{'$gen_event',{join,"cjk101010!ckruse@localhost","#selfhtml"}} ->
ok;
- _ ->
- throw({error, data_not_expected})
+ Dt ->
+ throw({error, data_not_expected, Dt})
after
5000 ->
throw({error, receive_timeout})
@@ -29,7 +29,7 @@
-define(setup(F), {setup, fun start/0, fun stop/1, F}).
start_stop_test() ->
- {ok, Pid} = irckerl_controller:start_link([]),
+ {ok, _Pid} = irckerl_controller:start_link([]),
irckerl_controller:stop().
created_test() ->
@@ -60,11 +60,31 @@ count_servers_test() ->
stop(Pid).
+register_client_test() ->
+ Pid = start(),
+ ?assert(is_pid(Pid)),
+ ?assertMatch(
+ ok,
+ gen_server:call(Pid, {register_client, self()})
+ ),
+ ?assertMatch(
+ ok,
+ gen_server:call(Pid, {choose_nick, "cjk101010", "cjk101010", #user{pid = self()}})
+ ),
+ ?assertMatch(
+ ok,
+ gen_server:call(Pid, {delete_nick, "cjk101010"})
+ ),
+ stop(Pid).
+
+
+
start() ->
{ok, Pid} = irckerl_controller:start_link([]),
Pid.
stop(Pid) ->
gen_server:call(Pid, stop).
+
% eof

0 comments on commit 0ba9b28

Please sign in to comment.