Skip to content

Commit

Permalink
fixing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysGonchar committed Apr 3, 2021
1 parent 05b6c6d commit a39052b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions test/commands_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ init_per_testcase(_, C) ->
meck:expect(ejabberd_config, get_global_option, fun ggo/1),
meck:new(ejabberd_auth_dummy, [non_strict]),
meck:expect(ejabberd_auth_dummy, get_password_s, fun(_, _) -> <<"">> end),
meck:new(mongoose_domain_api),
meck:expect(mongoose_domain_api, get_host_type, fun(H) -> {ok, H} end),
C.

end_per_testcase(_, C) ->
meck:unload(ejabberd_config),
meck:unload(ejabberd_auth_dummy),
meck:unload(),
C.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
8 changes: 7 additions & 1 deletion test/ejabberd_c2s_SUITE_mocks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ setup() ->
meck:expect(mongoose_metrics, update, fun (_, _, _) -> ok end),

meck:new(gen_mod),
meck:expect(gen_mod, is_loaded, fun (_, _) -> true end).
meck:expect(gen_mod, is_loaded, fun (_, _) -> true end),

meck:new(mongoose_domain_api),
meck:expect(mongoose_domain_api, get_host_type, fun get_host_type/1).


teardown() ->
Expand All @@ -79,3 +82,6 @@ hookfold(session_opening_allowed_for_user, _, _, _) -> allow;
hookfold(c2s_stream_features, _, _, _) -> [];
hookfold(xmpp_send_element, _, A, _) -> A;
hookfold(privacy_check_packet, _, _, _) -> allow.

get_host_type(<<"localhost">>) -> {ok, <<"localhost">>};
get_host_type(_) -> {error, not_found}.

0 comments on commit a39052b

Please sign in to comment.