Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Fix EUnit tests.
 Need couch_log. In one case mock it becuase no other apps are started.

 In another use application:ensure_all_started() -- R16B02+ feature.
  • Loading branch information
nickva committed Oct 6, 2015
1 parent fb5f56c commit 2b71bc9224d99eb6269386ea8426239a03dd53ba
Showing 1 changed file with 28 additions and 10 deletions.
@@ -120,27 +120,45 @@ build_shards_test() ->

%% n_val tests

nval_test() ->
?assertEqual(2, mem3_util:n_val(2,4)),
?assertEqual(1, mem3_util:n_val(-1,4)),
?assertEqual(4, mem3_util:n_val(6,4)),
ok.
nval_test_() ->
{"n_val tests explicit",
[
{setup,
fun () ->
meck:new([couch_log]),
meck:expect(couch_log, error, fun(_, _) -> ok end),
ok
end,
fun (_) -> meck:unload([couch_log]) end,
[
?_assertEqual(2, mem3_util:n_val(2,4)),
?_assertEqual(1, mem3_util:n_val(-1,4)),
?_assertEqual(4, mem3_util:n_val(6,4))
]
}
]
}.


config_01_setup() ->
{ok, Started} = application:ensure_all_started(couch_log),
Ini = filename:join([code:lib_dir(mem3, test), "01-config-default.ini"]),
{ok, Pid} = config:start_link([Ini]),
Pid.
{Pid, Started}.

config_teardown({_Pid, Started}) ->
config:stop(),
[ok = application:stop(A) || A <- lists:reverse(Started)],
ok.

config_teardown(_Pid) ->
config:stop().

n_val_test_() ->
{"n_val tests",
{"n_val tests with config",
[
{setup,
fun config_01_setup/0,
fun config_teardown/1,
fun(Pid) ->
fun({Pid, _Started}) ->
{with, Pid, [
fun n_val_1/1
]}

0 comments on commit 2b71bc9

Please sign in to comment.