Przeglądaj źródła

fix(listeners): update the testcases for listeners

Shawn 4 lat temu
rodzic
commit
7e53469bb8

+ 4 - 0
apps/emqx/src/emqx_config_handler.erl

@@ -23,6 +23,7 @@
 
 
 %% API functions
 %% API functions
 -export([ start_link/0
 -export([ start_link/0
+        , stop/0
         , add_handler/2
         , add_handler/2
         , remove_handler/1
         , remove_handler/1
         , update_config/3
         , update_config/3
@@ -68,6 +69,9 @@
 start_link() ->
 start_link() ->
     gen_server:start_link({local, ?MODULE}, ?MODULE, {}, []).
     gen_server:start_link({local, ?MODULE}, ?MODULE, {}, []).
 
 
+stop() ->
+    gen_server:stop(?MODULE).
+
 -spec update_config(module(), emqx_config:config_key_path(), emqx_config:update_args()) ->
 -spec update_config(module(), emqx_config:config_key_path(), emqx_config:update_args()) ->
     {ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
     {ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
 update_config(SchemaModule, ConfKeyPath, UpdateArgs) ->
 update_config(SchemaModule, ConfKeyPath, UpdateArgs) ->

+ 8 - 0
apps/emqx/test/emqx_listeners_SUITE.erl

@@ -37,6 +37,14 @@ end_per_suite(_Config) ->
     application:stop(esockd),
     application:stop(esockd),
     application:stop(cowboy).
     application:stop(cowboy).
 
 
+init_per_testcase(_, Config) ->
+    {ok, _} = emqx_config_handler:start_link(),
+    Config.
+
+end_per_testcase(_, _Config) ->
+    _ = emqx_config_handler:stop(),
+    ok.
+
 t_start_stop_listeners(_) ->
 t_start_stop_listeners(_) ->
     ok = emqx_listeners:start(),
     ok = emqx_listeners:start(),
     ?assertException(error, _, emqx_listeners:start_listener({ws,{"127.0.0.1", 8083}, []})),
     ?assertException(error, _, emqx_listeners:start_listener({ws,{"127.0.0.1", 8083}, []})),