test: make sure mocks are ready before init_mocks terminates

This commit is contained in:
Stefan Strigler 2023-10-12 07:27:42 +02:00 committed by Zaiming (Stone) Shi
parent ee8e469086
commit 0ad156bfa9
1 changed files with 21 additions and 7 deletions

View File

@ -195,14 +195,28 @@ end_per_testcase(_TestCase, Config) ->
ok = erpc:call(Node, fun clear_resources/0), ok = erpc:call(Node, fun clear_resources/0),
ok. ok.
loop(Mocks) ->
receive
{get_mocks, Pid} ->
Pid ! {mocks, Mocks},
loop(Mocks);
stop_mocks ->
meck:unload()
end.
inject_mocks() -> inject_mocks() ->
_Pid = spawn(fun() -> Pid = spawn(fun() ->
_Mocks = ?MODULE:init_mocks(), Mocks = ?MODULE:init_mocks(),
receive loop(Mocks)
stop_mocks -> end),
meck:unload() %% make sure mocks are ready before we leave
end Pid ! {get_mocks, self()},
end). receive
{mocks, _Mocks} ->
%% ct:pal("received mocks! ~p", [_Mocks]),
ok
end,
Pid.
-define(CONNECTOR_IMPL, dummy_connector_impl). -define(CONNECTOR_IMPL, dummy_connector_impl).
init_mocks() -> init_mocks() ->