Merge pull request #7380 from zmstone/test-fix-data-import-case-failure
test: fix data import test failure
This commit is contained in:
commit
a39cc47a45
|
@ -292,8 +292,7 @@ t_subscriptions_cmd(_) ->
|
||||||
[?assertMatch({match, _} , re:run(Result, "b/b/c"))
|
[?assertMatch({match, _} , re:run(Result, "b/b/c"))
|
||||||
|| Result <- emqx_mgmt_cli:subscriptions(["show", <<"client">>])],
|
|| Result <- emqx_mgmt_cli:subscriptions(["show", <<"client">>])],
|
||||||
?assertEqual(emqx_mgmt_cli:subscriptions(["add", "client", "b/b/c", "0"]), "ok\n"),
|
?assertEqual(emqx_mgmt_cli:subscriptions(["add", "client", "b/b/c", "0"]), "ok\n"),
|
||||||
?assertEqual(emqx_mgmt_cli:subscriptions(["del", "client", "b/b/c"]), "ok\n"),
|
?assertEqual(emqx_mgmt_cli:subscriptions(["del", "client", "b/b/c"]), "ok\n").
|
||||||
unmock_print().
|
|
||||||
|
|
||||||
t_listeners_cmd_old(_) ->
|
t_listeners_cmd_old(_) ->
|
||||||
ok = emqx_listeners:ensure_all_started(),
|
ok = emqx_listeners:ensure_all_started(),
|
||||||
|
@ -322,8 +321,7 @@ t_listeners_cmd_new(_) ->
|
||||||
emqx_mgmt_cli:listeners(["restart", "bad:listener:identifier"]),
|
emqx_mgmt_cli:listeners(["restart", "bad:listener:identifier"]),
|
||||||
"Failed to restart bad:listener:identifier listener:"
|
"Failed to restart bad:listener:identifier listener:"
|
||||||
" {no_such_listener,\"bad:listener:identifier\"}\n"
|
" {no_such_listener,\"bad:listener:identifier\"}\n"
|
||||||
),
|
).
|
||||||
unmock_print().
|
|
||||||
|
|
||||||
t_plugins_cmd(_) ->
|
t_plugins_cmd(_) ->
|
||||||
?assertEqual(emqx_mgmt_cli:plugins(["list"]), ok),
|
?assertEqual(emqx_mgmt_cli:plugins(["list"]), ok),
|
||||||
|
@ -338,8 +336,7 @@ t_plugins_cmd(_) ->
|
||||||
?assertEqual(
|
?assertEqual(
|
||||||
emqx_mgmt_cli:plugins(["unload", "emqx_management"]),
|
emqx_mgmt_cli:plugins(["unload", "emqx_management"]),
|
||||||
"Plugin emqx_management can not be unloaded.\n"
|
"Plugin emqx_management can not be unloaded.\n"
|
||||||
),
|
).
|
||||||
unmock_print().
|
|
||||||
|
|
||||||
t_cli(_) ->
|
t_cli(_) ->
|
||||||
?assertMatch({match, _}, re:run(emqx_mgmt_cli:status([""]), "status")),
|
?assertMatch({match, _}, re:run(emqx_mgmt_cli:status([""]), "status")),
|
||||||
|
@ -388,7 +385,7 @@ t_backup_file(_)->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
mock_print() ->
|
mock_print() ->
|
||||||
catch meck:unload(emqx_ctl),
|
ok = safe_unmeck(emqx_ctl),
|
||||||
meck:new(emqx_ctl, [non_strict, passthrough]),
|
meck:new(emqx_ctl, [non_strict, passthrough]),
|
||||||
meck:expect(emqx_ctl, print, fun(Arg) -> emqx_ctl:format(Arg, []) end),
|
meck:expect(emqx_ctl, print, fun(Arg) -> emqx_ctl:format(Arg, []) end),
|
||||||
meck:expect(emqx_ctl, print, fun(Msg, Arg) -> emqx_ctl:format(Msg, Arg) end),
|
meck:expect(emqx_ctl, print, fun(Msg, Arg) -> emqx_ctl:format(Msg, Arg) end),
|
||||||
|
@ -397,3 +394,12 @@ mock_print() ->
|
||||||
|
|
||||||
unmock_print() ->
|
unmock_print() ->
|
||||||
meck:unload(emqx_ctl).
|
meck:unload(emqx_ctl).
|
||||||
|
|
||||||
|
safe_unmeck(Module) ->
|
||||||
|
try
|
||||||
|
meck:unload(Module),
|
||||||
|
ok
|
||||||
|
catch
|
||||||
|
_ : _ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
|
@ -60,7 +60,10 @@ t_import_4_3(Config) ->
|
||||||
|
|
||||||
import(File, Config) ->
|
import(File, Config) ->
|
||||||
Filename = filename:join(proplists:get_value(data_dir, Config), File),
|
Filename = filename:join(proplists:get_value(data_dir, Config), File),
|
||||||
emqx_mgmt_data_backup:import(Filename, "{}").
|
{ok, Content} = file:read_file(Filename),
|
||||||
|
BackupFile = filename:join(emqx:get_env(data_dir), File),
|
||||||
|
ok = file:write_file(BackupFile, Content),
|
||||||
|
emqx_mgmt_data_backup:import(File, "{}").
|
||||||
|
|
||||||
delete_modules() ->
|
delete_modules() ->
|
||||||
[emqx_modules_registry:remove_module(Mod) || Mod <- emqx_modules_registry:get_modules()].
|
[emqx_modules_registry:remove_module(Mod) || Mod <- emqx_modules_registry:get_modules()].
|
||||||
|
|
Loading…
Reference in New Issue