Sfoglia il codice sorgente

Merge pull request #3343 from emqx/fix_test_case

Fix plugin test case
tigercl 5 anni fa
parent
commit
0ff1e9eadb
2 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 2 2
      src/emqx_plugins.erl
  2. 4 1
      test/emqx_plugins_SUITE.erl

+ 2 - 2
src/emqx_plugins.erl

@@ -252,8 +252,8 @@ plugin(AppName, Type) ->
 
 load_plugin(Name, Persistent) ->
     try
-        Configs = generate_configs(Name),
-        apply_configs(Configs),
+        Configs = ?MODULE:generate_configs(Name),
+        ?MODULE:apply_configs(Configs),
         case load_app(Name) of
             ok ->
                 start_app(Name, fun(App) -> plugin_loaded(App, Persistent) end);

+ 4 - 1
test/emqx_plugins_SUITE.erl

@@ -122,11 +122,14 @@ t_load_plugin(_) ->
     ok = meck:expect(application, ensure_all_started, fun(already_loaded_app) -> {error, {already_loaded_app, already_loaded}};
                                                          (error_app) -> {error, error};
                                                          (App) -> {ok, App} end),
-
+    ok = meck:new(emqx_plugins, [unstick, non_strict, passthrough, no_history]),
+    ok = meck:expect(emqx_plugins, generate_configs, fun(_) -> ok end),
+    ok = meck:expect(emqx_plugins, apply_configs, fun(_) -> ok end),
     ?assertMatch({error, _}, emqx_plugins:load_plugin(already_loaded_app, true)),
     ?assertMatch(ok, emqx_plugins:load_plugin(normal, true)),
     ?assertMatch({error,_}, emqx_plugins:load_plugin(error_app, true)),
 
+    ok = meck:unload(emqx_plugins),
     ok = meck:unload(application).
 
 t_unload_plugin(_) ->