From c5e88ab1a4993c5098324209702f8f237ad1d945 Mon Sep 17 00:00:00 2001 From: huangdan Date: Mon, 15 Aug 2016 15:36:52 +0800 Subject: [PATCH] emqttd_ctl eunit --- src/emqttd_ctl.erl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/emqttd_ctl.erl b/src/emqttd_ctl.erl index 2f406bef0..1cd5d3055 100644 --- a/src/emqttd_ctl.erl +++ b/src/emqttd_ctl.erl @@ -133,3 +133,20 @@ noreply(State) -> next_seq(State = #state{seq = Seq}) -> 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.