Unload meck before testcase ends
This commit is contained in:
parent
3a39442a1c
commit
2c07fc310e
|
@ -67,9 +67,10 @@ t_print(_) ->
|
||||||
ok = emqx_ctl:print("help"),
|
ok = emqx_ctl:print("help"),
|
||||||
ok = emqx_ctl:print("~s", [help]),
|
ok = emqx_ctl:print("~s", [help]),
|
||||||
% - check the output of the usage
|
% - check the output of the usage
|
||||||
print_mock(),
|
mock_print(),
|
||||||
?assertEqual("help", emqx_ctl:print("help")),
|
?assertEqual("help", emqx_ctl:print("help")),
|
||||||
?assertEqual("help", emqx_ctl:print("~s", [help])).
|
?assertEqual("help", emqx_ctl:print("~s", [help])),
|
||||||
|
unmock_print().
|
||||||
|
|
||||||
t_usage(_) ->
|
t_usage(_) ->
|
||||||
CmdParams1 = "emqx_cmd_1 param1 param2",
|
CmdParams1 = "emqx_cmd_1 param1 param2",
|
||||||
|
@ -80,7 +81,7 @@ t_usage(_) ->
|
||||||
ok = emqx_ctl:usage(CmdParams1, CmdDescr1),
|
ok = emqx_ctl:usage(CmdParams1, CmdDescr1),
|
||||||
|
|
||||||
% - check the output of the usage
|
% - check the output of the usage
|
||||||
print_mock(),
|
mock_print(),
|
||||||
?assertEqual(Output1, emqx_ctl:usage(CmdParams1, CmdDescr1)),
|
?assertEqual(Output1, emqx_ctl:usage(CmdParams1, CmdDescr1)),
|
||||||
?assertEqual([Output1, Output1], emqx_ctl:usage([{CmdParams1, CmdDescr1}, {CmdParams1, CmdDescr1}])),
|
?assertEqual([Output1, Output1], emqx_ctl:usage([{CmdParams1, CmdDescr1}, {CmdParams1, CmdDescr1}])),
|
||||||
|
|
||||||
|
@ -90,7 +91,8 @@ t_usage(_) ->
|
||||||
Output2 = "emqx_cmd_2 param1 param2 # emqx_cmd_2 is a test command\n"
|
Output2 = "emqx_cmd_2 param1 param2 # emqx_cmd_2 is a test command\n"
|
||||||
" ""# means nothing\n",
|
" ""# means nothing\n",
|
||||||
?assertEqual(Output2, emqx_ctl:usage(CmdParams2, CmdDescr2)),
|
?assertEqual(Output2, emqx_ctl:usage(CmdParams2, CmdDescr2)),
|
||||||
?assertEqual([Output2, Output2], emqx_ctl:usage([{CmdParams2, CmdDescr2}, {CmdParams2, CmdDescr2}])).
|
?assertEqual([Output2, Output2], emqx_ctl:usage([{CmdParams2, CmdDescr2}, {CmdParams2, CmdDescr2}])),
|
||||||
|
unmock_print().
|
||||||
|
|
||||||
t_unexpected(_) ->
|
t_unexpected(_) ->
|
||||||
with_ctl_server(
|
with_ctl_server(
|
||||||
|
@ -116,10 +118,13 @@ with_ctl_server(Fun) ->
|
||||||
_ = Fun(Pid),
|
_ = Fun(Pid),
|
||||||
ok = emqx_ctl:stop().
|
ok = emqx_ctl:stop().
|
||||||
|
|
||||||
print_mock() ->
|
mock_print() ->
|
||||||
%% proxy usage/1,2 and print/1,2 to format_xx/1,2 funcs
|
%% proxy usage/1,2 and print/1,2 to format_xx/1,2 funcs
|
||||||
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),
|
||||||
meck:expect(emqx_ctl, usage, fun(Usages) -> emqx_ctl:format_usage(Usages) end),
|
meck:expect(emqx_ctl, usage, fun(Usages) -> emqx_ctl:format_usage(Usages) end),
|
||||||
meck:expect(emqx_ctl, usage, fun(CmdParams, CmdDescr) -> emqx_ctl:format_usage(CmdParams, CmdDescr) end).
|
meck:expect(emqx_ctl, usage, fun(CmdParams, CmdDescr) -> emqx_ctl:format_usage(CmdParams, CmdDescr) end).
|
||||||
|
|
||||||
|
unmock_print() ->
|
||||||
|
meck:unload(emqx_ctl).
|
||||||
|
|
Loading…
Reference in New Issue