From 62cb3987347ec8d1bea8a9f9fb0bea6cfba98601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Fri, 29 Jun 2018 10:52:47 +0200 Subject: [PATCH] Convert test that used moka, and drop that dependancy --- rebar.config | 2 - test/mod_admin_extra_test.exs | 1 - test/mod_roster_mock.exs | 81 +---------------------------------- 3 files changed, 1 insertion(+), 83 deletions(-) diff --git a/rebar.config b/rebar.config index da827bca7..29d540d3e 100644 --- a/rebar.config +++ b/rebar.config @@ -57,8 +57,6 @@ {tag, "v0.3"}}}}, {if_var_true, tools, {meck, "0.8.*", {git, "https://github.com/eproxus/meck", {tag, "0.8.4"}}}}, - {if_var_true, tools, {moka, ".*", {git, "https://github.com/processone/moka", - {tag, "1.0.5d"}}}}, {if_var_true, redis, {eredis, ".*", {git, "https://github.com/wooga/eredis", {tag, "v1.0.8"}}}}]}. diff --git a/test/mod_admin_extra_test.exs b/test/mod_admin_extra_test.exs index 9b154fdb5..7b1bc21de 100644 --- a/test/mod_admin_extra_test.exs +++ b/test/mod_admin_extra_test.exs @@ -53,7 +53,6 @@ defmodule EjabberdModAdminExtraTest do :ejabberd_access_permissions.start_link() :ejabberd_commands.start_link :mod_admin_extra.start(@domain, []) - :sel_application.start_app(:moka) :ejabberd_hooks.start_link :ok end diff --git a/test/mod_roster_mock.exs b/test/mod_roster_mock.exs index 83182c196..70f273898 100644 --- a/test/mod_roster_mock.exs +++ b/test/mod_roster_mock.exs @@ -36,7 +36,7 @@ defmodule ModRosterMock do {:ok, _pid} = Agent.start_link(fn -> %{} end, name: @agent) - mock_with_moka module + mock_with_meck :ejabberd_mnesia.create(:mod_roster_mnesia, :roster, [ram_copies: [node()], @@ -49,85 +49,6 @@ defmodule ModRosterMock do :gen_mod.start_module(domain, :mod_roster) end - def mock_with_moka(module) do - try do - - module_mock = :moka.start(module) - :moka.replace(module_mock, :mod_roster_mnesia, :invalidate_roster_cache, - fn (_user, _server) -> - :ok - end) - - :moka.load(module_mock) - - roster_mock0 = :moka.start(:mod_roster) - :moka.replace(roster_mock0, :gen_iq_handler, :add_iq_handler, - fn (_module, _host, _ns, _m, _f) -> - :ok - end) - - :moka.replace(roster_mock0, :gen_iq_handler, :remove_iq_handler, - fn (_module, _host, _ns) -> - :ok - end) - :moka.replace(roster_mock0, :gen_mod, :db_mod, - fn (_host, _mod) -> - :mod_roster_mnesia - end) - :moka.replace(roster_mock0, :gen_mod, :db_mod, - fn (_host, _opts, _mod) -> - :mod_roster_mnesia - end) - :moka.replace(roster_mock0, :update_roster_t, - fn (user, domain, {u, d, _r}, item) -> - add_roster_item(user, domain, u<>"@"<>d, - roster(item, :name), - roster(item, :subscription), - roster(item, :groups), - roster(item, :ask), - roster(item, :askmessage)) - end) - - :moka.replace(roster_mock0, :del_roster_t, - fn (user, domain, jid) -> - remove_roster_item(user, domain, :jid.to_string(jid)) - end) - :moka.replace(roster_mock0, :get_roster, - fn (user, domain) -> - to_records(get_roster(user, domain)) - end) - - :moka.load(roster_mock0) - - roster_mock = :moka.start(:mod_roster_mnesia) - :moka.replace(roster_mock, :init, - fn (_host, _opts) -> - :ok - end) - - :moka.replace(roster_mock, :gen_mod, :db_type, - fn (_host, _opts) -> - {:none} - end) - - :moka.replace(roster_mock, :transaction, - fn (_server, function) -> - {:atomic, function.()} - end) - - :moka.replace(roster_mock, :update_tables, - fn () -> - :ok - end) - - :moka.load(roster_mock) - - catch - {:already_started, _pid} -> :ok - end - - end - def mock_with_meck do # mock(:gen_mod, :db_type, # fn (_server, :mod_roster_mnesia) ->