emqttd_ctl eunit

This commit is contained in:
huangdan 2016-08-15 15:36:52 +08:00
parent 8c1af879d3
commit c5e88ab1a4
1 changed files with 17 additions and 0 deletions

View File

@ -133,3 +133,20 @@ noreply(State) ->
next_seq(State = #state{seq = Seq}) -> next_seq(State = #state{seq = Seq}) ->
State#state{seq = Seq + 1}. State#state{seq = Seq + 1}.
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
register_cmd_test_() ->
{setup,
fun() ->
{ok, InitState} = emqttd_ctl:init([]),
InitState
end,
fun(State) ->
ok = emqttd_ctl:terminate(shutdown, State)
end,
fun(State = #state{seq = Seq}) ->
emqttd_ctl:handle_cast({register_cmd, test0, {?MODULE, test0}, []}, State),
[?_assertMatch([{{0,test0},{?MODULE, test0}, []}], ets:lookup(?CMD_TAB, {Seq,test0}))]
end
}.
-endif.