Fix plugin test case

This commit is contained in:
zhouzb 2020-03-27 15:31:11 +08:00
parent 55a8b1b173
commit 792a14aaf7
2 changed files with 6 additions and 3 deletions

View File

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

View File

@ -122,11 +122,14 @@ t_load_plugin(_) ->
ok = meck:expect(application, ensure_all_started, fun(already_loaded_app) -> {error, {already_loaded_app, already_loaded}}; ok = meck:expect(application, ensure_all_started, fun(already_loaded_app) -> {error, {already_loaded_app, already_loaded}};
(error_app) -> {error, error}; (error_app) -> {error, error};
(App) -> {ok, App} end), (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({error, _}, emqx_plugins:load_plugin(already_loaded_app, true)),
?assertMatch(ok, emqx_plugins:load_plugin(normal, true)), ?assertMatch(ok, emqx_plugins:load_plugin(normal, true)),
?assertMatch({error,_}, emqx_plugins:load_plugin(error_app, true)), ?assertMatch({error,_}, emqx_plugins:load_plugin(error_app, true)),
ok = meck:unload(emqx_plugins),
ok = meck:unload(application). ok = meck:unload(application).
t_unload_plugin(_) -> t_unload_plugin(_) ->