You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ji...@apache.org on 2025/03/12 20:15:39 UTC
(couchdb) 01/01: chore: Clean up `meck` functions in `fabric`
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch cleanup-meck-in-fabric
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit b91bd115ce15fbb6c4d2e6ec3d7d789dd8abd5b6
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Wed Mar 12 13:52:33 2025 -0500
chore: Clean up `meck` functions in `fabric`
After upgrading `meck`, CI got errors about `context setup failed`.
Cleaning up `meck` functions in `fabric` to fix this issue.
```
[2025-03-12T20:04:15.632Z] module 'fabric_view_map'
[2025-03-12T20:04:16.552Z] fabric_view_map_meck_original:330: -handle_message_test_/0-fun-20- (t_handle_message_rexi_down)...[0.005 s] ok
[2025-03-12T20:04:17.472Z] undefined
[2025-03-12T20:04:17.472Z] *** context setup failed ***
[2025-03-12T20:04:17.472Z] **in function persistent_term:get/1
[2025-03-12T20:04:17.472Z] called as get({cover,fabric_view_map_meck_original})
[2025-03-12T20:04:17.472Z] in call from fabric_view_map_meck_original:'-handle_message_test_/0-fun-23-'/0
[2025-03-12T20:04:17.472Z] **error:badarg
```
---
src/fabric/src/fabric_db_create.erl | 2 +-
src/fabric/src/fabric_doc_open.erl | 54 ++++++-------
src/fabric/src/fabric_doc_open_revs.erl | 14 ++--
src/fabric/src/fabric_doc_purge.erl | 8 +-
src/fabric/src/fabric_doc_update.erl | 6 +-
src/fabric/src/fabric_open_revs.erl | 24 +++---
src/fabric/src/fabric_ring.erl | 5 +-
src/fabric/src/fabric_rpc.erl | 28 +++----
src/fabric/src/fabric_streams.erl | 28 +++----
src/fabric/src/fabric_view.erl | 34 ++++----
src/fabric/src/fabric_view_all_docs.erl | 90 +++++++++++++---------
src/fabric/src/fabric_view_changes.erl | 11 ++-
src/fabric/src/fabric_view_map.erl | 39 +++++-----
src/fabric/src/fabric_view_reduce.erl | 25 +++---
src/fabric/test/eunit/fabric_db_create_tests.erl | 13 ++--
src/fabric/test/eunit/fabric_db_info_tests.erl | 1 -
src/fabric/test/eunit/fabric_db_uuids_tests.erl | 1 -
.../test/eunit/fabric_moved_shards_seq_tests.erl | 4 +-
src/fabric/test/eunit/fabric_open_revs_test.erl | 6 +-
src/fabric/test/eunit/fabric_tests.erl | 22 ++++--
20 files changed, 228 insertions(+), 187 deletions(-)
diff --git a/src/fabric/src/fabric_db_create.erl b/src/fabric/src/fabric_db_create.erl
index 71375f5a8..3b97be6e2 100644
--- a/src/fabric/src/fabric_db_create.erl
+++ b/src/fabric/src/fabric_db_create.erl
@@ -212,7 +212,7 @@ db_exists_test_() ->
}.
setup_all() ->
- meck:new(mem3).
+ ok = meck:new(mem3).
teardown_all(_) ->
meck:unload().
diff --git a/src/fabric/src/fabric_doc_open.erl b/src/fabric/src/fabric_doc_open.erl
index 3ad019039..d6063907e 100644
--- a/src/fabric/src/fabric_doc_open.erl
+++ b/src/fabric/src/fabric_doc_open.erl
@@ -209,13 +209,13 @@ format_reply(Else, _) ->
]).
setup_all() ->
- meck:new(?MECK_MODS, [passthrough]).
+ ok = meck:new(?MECK_MODS, [passthrough]).
teardown_all(_) ->
meck:unload().
setup() ->
- meck:reset(?MECK_MODS).
+ ok = meck:reset(?MECK_MODS).
teardown(_) ->
ok.
@@ -351,7 +351,7 @@ t_handle_message_reply() ->
Acc0 = #acc{workers = Workers, r = 2, replies = []},
?_test(begin
- meck:expect(rexi, kill_all, fun(_) -> ok end),
+ ok = meck:expect(rexi, kill_all, fun(_) -> ok end),
% Test that we continue when we haven't met R yet
?assertMatch(
@@ -444,7 +444,7 @@ t_store_node_revs() ->
InitAcc = #acc{workers = [W1, W2, W3], replies = [], r = 2},
?_test(begin
- meck:expect(rexi, kill_all, fun(_) -> ok end),
+ ok = meck:expect(rexi, kill_all, fun(_) -> ok end),
% Simple case
{ok, #acc{node_revs = NodeRevs1}} = handle_message(Foo1, W1, InitAcc),
@@ -497,18 +497,18 @@ t_read_repair() ->
NFM = {not_found, missing},
?_test(begin
- meck:expect(couch_log, notice, fun(_, _) -> ok end),
- meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+ ok = meck:expect(couch_log, notice, fun(_, _) -> ok end),
+ ok = meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
% Test when we have actual doc data to repair
- meck:expect(fabric, update_docs, fun(_, [_], _) -> {ok, []} end),
+ ok = meck:expect(fabric, update_docs, fun(_, [_], _) -> {ok, []} end),
Acc0 = #acc{
dbname = <<"name">>,
replies = [fabric_util:kv(Foo1, 1)]
},
?assertEqual(Foo1, read_repair(Acc0)),
- meck:expect(fabric, update_docs, fun(_, [_, _], _) -> {ok, []} end),
+ ok = meck:expect(fabric, update_docs, fun(_, [_, _], _) -> {ok, []} end),
Acc1 = #acc{
dbname = <<"name">>,
replies = [fabric_util:kv(Foo1, 1), fabric_util:kv(Foo2, 1)]
@@ -530,11 +530,11 @@ t_no_read_repair_for_replicator() ->
Foo1 = {ok, #doc{revs = {1, [<<"foo">>]}}},
?_test(begin
- meck:expect(couch_log, notice, fun(_, _) -> ok end),
- meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+ ok = meck:expect(couch_log, notice, fun(_, _) -> ok end),
+ ok = meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
% Test no read_repair took place
- meck:reset(fabric),
+ ok = meck:reset(fabric),
Acc0 = #acc{
dbname = <<"dbname1/_replicator">>,
replies = [fabric_util:kv(Foo1, 1)]
@@ -550,9 +550,9 @@ t_handle_response_quorum_met() ->
Bar1 = {ok, #doc{revs = {1, [<<"bar">>]}}},
?_test(begin
- meck:expect(couch_log, notice, fun(_, _) -> ok end),
- meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, []} end),
- meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+ ok = meck:expect(couch_log, notice, fun(_, _) -> ok end),
+ ok = meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, []} end),
+ ok = meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
BasicOkAcc = #acc{
dbname = <<"dbname1">>,
@@ -596,16 +596,16 @@ t_handle_response_quorum_met() ->
t_get_doc_info() ->
?_test(begin
- meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, []} end),
- meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
- meck:expect(fabric_util, submit_jobs, fun(_, _, _) -> ok end),
- meck:expect(fabric_util, create_monitors, fun(_) -> ok end),
- meck:expect(rexi_monitor, stop, fun(_) -> ok end),
- meck:expect(mem3, shards, fun(_, _) -> ok end),
- meck:expect(mem3, n, fun(_) -> 3 end),
- meck:expect(mem3, quorum, fun(_) -> 2 end),
-
- meck:expect(fabric_util, recv, fun(_, _, _, _) ->
+ ok = meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, []} end),
+ ok = meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+ ok = meck:expect(fabric_util, submit_jobs, fun(_, _, _) -> ok end),
+ ok = meck:expect(fabric_util, create_monitors, fun(_) -> ok end),
+ ok = meck:expect(rexi_monitor, stop, fun(_) -> ok end),
+ ok = meck:expect(mem3, shards, fun(_, _) -> ok end),
+ ok = meck:expect(mem3, n, fun(_) -> 3 end),
+ ok = meck:expect(mem3, quorum, fun(_) -> 2 end),
+
+ ok = meck:expect(fabric_util, recv, fun(_, _, _, _) ->
{ok, #acc{state = r_not_met}}
end),
Rsp1 = fabric_doc_open:go("test", "one", [doc_info]),
@@ -614,7 +614,7 @@ t_get_doc_info() ->
Rsp2 = fabric_doc_open:go("test", "one", [{doc_info, full}]),
?assertEqual({error, quorum_not_met}, Rsp2),
- meck:expect(fabric_util, recv, fun(_, _, _, _) ->
+ ok = meck:expect(fabric_util, recv, fun(_, _, _, _) ->
{ok, #acc{state = r_met, q_reply = not_found}}
end),
MissingRsp1 = fabric_doc_open:go("test", "one", [doc_info]),
@@ -622,14 +622,14 @@ t_get_doc_info() ->
MissingRsp2 = fabric_doc_open:go("test", "one", [{doc_info, full}]),
?assertEqual({not_found, missing}, MissingRsp2),
- meck:expect(fabric_util, recv, fun(_, _, _, _) ->
+ ok = meck:expect(fabric_util, recv, fun(_, _, _, _) ->
A = #doc_info{},
{ok, #acc{state = r_met, q_reply = {ok, A}}}
end),
{ok, Rec1} = fabric_doc_open:go("test", "one", [doc_info]),
?assert(is_record(Rec1, doc_info)),
- meck:expect(fabric_util, recv, fun(_, _, _, _) ->
+ ok = meck:expect(fabric_util, recv, fun(_, _, _, _) ->
A = #full_doc_info{deleted = true},
{ok, #acc{state = r_met, q_reply = {ok, A}}}
end),
diff --git a/src/fabric/src/fabric_doc_open_revs.erl b/src/fabric/src/fabric_doc_open_revs.erl
index ff1948735..2e4b4aade 100644
--- a/src/fabric/src/fabric_doc_open_revs.erl
+++ b/src/fabric/src/fabric_doc_open_revs.erl
@@ -327,19 +327,19 @@ collapse_duplicate_revs_int([Reply | Rest]) ->
setup_all() ->
config:start_link([]),
- meck:new([fabric, couch_stats, couch_log]),
- meck:new(fabric_util, [passthrough]),
- meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, nil} end),
- meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
- meck:expect(couch_log, notice, fun(_, _) -> ok end),
- meck:expect(fabric_util, cleanup, fun(_) -> ok end).
+ ok = meck:new([fabric, couch_stats, couch_log]),
+ ok = meck:new(fabric_util, [passthrough]),
+ ok = meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, nil} end),
+ ok = meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+ ok = meck:expect(couch_log, notice, fun(_, _) -> ok end),
+ ok = meck:expect(fabric_util, cleanup, fun(_) -> ok end).
teardown_all(_) ->
meck:unload(),
config:stop().
setup() ->
- meck:reset([
+ ok = meck:reset([
couch_log,
couch_stats,
fabric,
diff --git a/src/fabric/src/fabric_doc_purge.erl b/src/fabric/src/fabric_doc_purge.erl
index 5405ceb60..3854c56d7 100644
--- a/src/fabric/src/fabric_doc_purge.erl
+++ b/src/fabric/src/fabric_doc_purge.erl
@@ -267,10 +267,10 @@ purge_test_() ->
}.
setup() ->
- meck:new(couch_log),
- meck:expect(couch_log, warning, fun(_, _) -> ok end),
- meck:expect(couch_log, notice, fun(_, _) -> ok end),
- meck:expect(couch_log, error, fun(_, _) -> ok end).
+ ok = meck:new(couch_log),
+ ok = meck:expect(couch_log, warning, fun(_, _) -> ok end),
+ ok = meck:expect(couch_log, notice, fun(_, _) -> ok end),
+ ok = meck:expect(couch_log, error, fun(_, _) -> ok end).
teardown(_) ->
meck:unload().
diff --git a/src/fabric/src/fabric_doc_update.erl b/src/fabric/src/fabric_doc_update.erl
index 1f5755de0..44d5f2de5 100644
--- a/src/fabric/src/fabric_doc_update.erl
+++ b/src/fabric/src/fabric_doc_update.erl
@@ -356,9 +356,9 @@ validate_atomic_update(_DbName, AllDocs, true) ->
-include_lib("eunit/include/eunit.hrl").
setup_all() ->
- meck:new([couch_log, couch_stats]),
- meck:expect(couch_log, warning, fun(_, _) -> ok end),
- meck:expect(couch_stats, increment_counter, fun(_) -> ok end).
+ ok = meck:new([couch_log, couch_stats]),
+ ok = meck:expect(couch_log, warning, fun(_, _) -> ok end),
+ ok = meck:expect(couch_stats, increment_counter, fun(_) -> ok end).
teardown_all(_) ->
meck:unload().
diff --git a/src/fabric/src/fabric_open_revs.erl b/src/fabric/src/fabric_open_revs.erl
index b0a54645a..32fe08e10 100644
--- a/src/fabric/src/fabric_open_revs.erl
+++ b/src/fabric/src/fabric_open_revs.erl
@@ -259,26 +259,26 @@ stop_workers(#{} = Workers) ->
setup_all() ->
config:start_link([]),
- meck:new([fabric, couch_stats, couch_log]),
- meck:new(rexi, [passthrough]),
- meck:new(mem3, [passthrough]),
- meck:new(fabric_util, [passthrough]),
- meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, nil} end),
- meck:expect(mem3, quorum, fun(_) -> 2 end),
- meck:expect(mem3, shards, fun(<<"db">>, <<"a">>) ->
+ ok = meck:new([fabric, couch_stats, couch_log]),
+ ok = meck:new(rexi, [passthrough]),
+ ok = meck:new(mem3, [passthrough]),
+ ok = meck:new(fabric_util, [passthrough]),
+ ok = meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, nil} end),
+ ok = meck:expect(mem3, quorum, fun(_) -> 2 end),
+ ok = meck:expect(mem3, shards, fun(<<"db">>, <<"a">>) ->
[#shard{node = 'n1'}, #shard{node = 'n2'}, #shard{node = 'n3'}]
end),
- meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
- meck:expect(couch_log, notice, fun(_, _) -> ok end),
- meck:expect(rexi, cast, fun(_, _) -> make_ref() end),
- meck:expect(rexi, kill_all, fun(_) -> ok end).
+ ok = meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+ ok = meck:expect(couch_log, notice, fun(_, _) -> ok end),
+ ok = meck:expect(rexi, cast, fun(_, _) -> make_ref() end),
+ ok = meck:expect(rexi, kill_all, fun(_) -> ok end).
teardown_all(_) ->
meck:unload(),
config:stop().
setup() ->
- meck:reset([
+ ok = meck:reset([
couch_log,
mem3,
rexi,
diff --git a/src/fabric/src/fabric_ring.erl b/src/fabric/src/fabric_ring.erl
index 3973892d4..a66d4d7e4 100644
--- a/src/fabric/src/fabric_ring.erl
+++ b/src/fabric/src/fabric_ring.erl
@@ -630,9 +630,8 @@ handle_response_cleanup_callback_test_() ->
}.
setup() ->
- meck:new(rexi, [passthrough]),
- meck:expect(rexi, kill_all, 1, ok),
- ok.
+ ok = meck:new(rexi, [passthrough]),
+ ok = meck:expect(rexi, kill_all, 1, ok).
teardown(_) ->
meck:unload().
diff --git a/src/fabric/src/fabric_rpc.erl b/src/fabric/src/fabric_rpc.erl
index 67f529e09..2ad316ee3 100644
--- a/src/fabric/src/fabric_rpc.erl
+++ b/src/fabric/src/fabric_rpc.erl
@@ -726,7 +726,7 @@ maybe_filtered_json_doc_with_filter_test() ->
view_cb_test_() ->
{
foreach,
- fun() -> meck:new(rexi) end,
+ fun() -> ok = meck:new(rexi) end,
fun(_) -> meck:unload() end,
[
?TDEF_FE(t_view_cb_meta),
@@ -739,39 +739,39 @@ view_cb_test_() ->
}.
t_view_cb_meta(_) ->
- meck:expect(rexi, stream2, [{meta, meta}], meck:val(ok)),
+ ok = meck:expect(rexi, stream2, [{meta, meta}], meck:val(ok)),
?assertEqual({ok, acc}, view_cb({meta, meta}, acc)).
t_view_cb_row_record(_) ->
Acc = #mrargs{},
Props = [{id, id}, {key, key}, {value, value}],
ViewRow = #view_row{id = id, key = key, value = value},
- meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
+ ok = meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
?assertEqual({ok, Acc}, view_cb({row, Props}, Acc)).
t_view_cb_row_map(_) ->
Acc = #mrargs{extra = [{view_row_map, true}]},
Props = [{id, id}, {key, key}, {value, value}],
ViewRow = {view_row, #{id => id, key => key, value => value}},
- meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
+ ok = meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
?assertEqual({ok, Acc}, view_cb({row, Props}, Acc)).
t_view_cb_complete(_) ->
- meck:expect(rexi, stream_last, [complete], meck:val(ok)),
+ ok = meck:expect(rexi, stream_last, [complete], meck:val(ok)),
?assertEqual({ok, acc}, view_cb(complete, acc)).
t_view_cb_ddoc_updated(_) ->
- meck:expect(rexi, reply, [{ok, ddoc_updated}], meck:val(ok)),
+ ok = meck:expect(rexi, reply, [{ok, ddoc_updated}], meck:val(ok)),
?assertEqual(ok, view_cb(ok, ddoc_updated)).
t_view_cb_insufficient_storage(_) ->
- meck:expect(rexi, reply, [{ok, insufficient_storage}], meck:val(ok)),
+ ok = meck:expect(rexi, reply, [{ok, insufficient_storage}], meck:val(ok)),
?assertEqual(ok, view_cb(ok, insufficient_storage)).
reduce_cb_test_() ->
{
foreach,
- fun() -> meck:new(rexi) end,
+ fun() -> ok = meck:new(rexi) end,
fun(_) -> meck:unload() end,
[
?TDEF_FE(t_reduce_cb_meta),
@@ -784,33 +784,33 @@ reduce_cb_test_() ->
}.
t_reduce_cb_meta(_) ->
- meck:expect(rexi, stream2, [{meta, meta}], meck:val(ok)),
+ ok = meck:expect(rexi, stream2, [{meta, meta}], meck:val(ok)),
?assertEqual({ok, acc}, reduce_cb({meta, meta}, acc, options)).
t_reduce_cb_row_record(_) ->
Options = [],
Props = [{id, id}, {key, key}, {value, value}],
ViewRow = #view_row{id = id, key = key, value = value},
- meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
+ ok = meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
?assertEqual({ok, acc}, reduce_cb({row, Props}, acc, Options)).
t_reduce_cb_row_map(_) ->
Options = [{view_row_map, true}],
Props = [{id, id}, {key, key}, {value, value}],
ViewRow = {view_row, #{id => id, key => key, value => value}},
- meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
+ ok = meck:expect(rexi, stream2, [ViewRow], meck:val(ok)),
?assertEqual({ok, acc}, reduce_cb({row, Props}, acc, Options)).
t_reduce_cb_complete(_) ->
- meck:expect(rexi, stream_last, [complete], meck:val(ok)),
+ ok = meck:expect(rexi, stream_last, [complete], meck:val(ok)),
?assertEqual({ok, acc}, reduce_cb(complete, acc, options)).
t_reduce_cb_ddoc_updated(_) ->
- meck:expect(rexi, reply, [{ok, ddoc_updated}], meck:val(ok)),
+ ok = meck:expect(rexi, reply, [{ok, ddoc_updated}], meck:val(ok)),
?assertEqual(ok, reduce_cb(ok, ddoc_updated, options)).
t_reduce_cb_insufficient_storage(_) ->
- meck:expect(rexi, reply, [{ok, insufficient_storage}], meck:val(ok)),
+ ok = meck:expect(rexi, reply, [{ok, insufficient_storage}], meck:val(ok)),
?assertEqual(ok, reduce_cb(ok, insufficient_storage, options)).
-endif.
diff --git a/src/fabric/src/fabric_streams.erl b/src/fabric/src/fabric_streams.erl
index af2284f9f..2aa44f0a2 100644
--- a/src/fabric/src/fabric_streams.erl
+++ b/src/fabric/src/fabric_streams.erl
@@ -260,7 +260,7 @@ worker_cleaner_test_() ->
}.
should_clean_workers(_) ->
- meck:reset(rexi),
+ ok = meck:reset(rexi),
erase(?WORKER_CLEANER),
Workers = [
#shard{node = 'n1', ref = make_ref()},
@@ -280,7 +280,7 @@ should_clean_workers(_) ->
?assertEqual(1, meck:num_calls(rexi, kill_all, 1)).
does_not_fire_if_cleanup_called(_) ->
- meck:reset(rexi),
+ ok = meck:reset(rexi),
erase(?WORKER_CLEANER),
Workers = [
#shard{node = 'n1', ref = make_ref()},
@@ -323,7 +323,7 @@ should_clean_additional_worker_too(_) ->
?assertEqual(1, meck:num_calls(rexi, kill_all, 1)).
coordinator_is_killed_if_client_disconnects(_) ->
- meck:reset(rexi),
+ ok = meck:reset(rexi),
erase(?WORKER_CLEANER),
Workers = [
#shard{node = 'n1', ref = make_ref()},
@@ -366,7 +366,7 @@ coordinator_is_killed_if_client_disconnects(_) ->
end.
coordinator_is_not_killed_if_client_is_connected(_) ->
- meck:reset(rexi),
+ ok = meck:reset(rexi),
erase(?WORKER_CLEANER),
Workers = [
#shard{node = 'n1', ref = make_ref()},
@@ -399,13 +399,13 @@ coordinator_is_not_killed_if_client_is_connected(_) ->
end.
submit_jobs_sets_up_cleaner(_) ->
- meck:reset(rexi),
+ ok = meck:reset(rexi),
erase(?WORKER_CLEANER),
Shards = [
#shard{node = 'n1'},
#shard{node = 'n2'}
],
- meck:expect(rexi, cast_ref, fun(Ref, _, _) -> Ref end),
+ ok = meck:expect(rexi, cast_ref, fun(Ref, _, _) -> Ref end),
{Coord, CoordRef} = spawn_monitor(fun() ->
Workers = submit_jobs(Shards, fabric_rpc, potatoes, []),
receive
@@ -430,9 +430,9 @@ submit_jobs_sets_up_cleaner(_) ->
?assertEqual(length(Shards), length(Workers)),
?assertEqual(length(lists:usort(NodeRefs)), length(NodeRefs)),
% Were the jobs actually submitted?
- meck:wait(2, rexi, cast_ref, '_', 1000),
+ ok = meck:wait(2, rexi, cast_ref, '_', 1000),
% If we kill the coordinator, the cleaner should kill the workers
- meck:reset(rexi),
+ ok = meck:reset(rexi),
CleanupMon = erlang:monitor(process, Cleaner),
exit(Coord, kill),
receive
@@ -442,7 +442,7 @@ submit_jobs_sets_up_cleaner(_) ->
?assert(is_process_alive(Coord))
end,
% Cleaner should do the cleanup
- meck:wait(1, rexi, kill_all, '_', 1000),
+ ok = meck:wait(1, rexi, kill_all, '_', 1000),
History = meck:history(rexi),
?assertMatch([{_, {rexi, kill_all, _}, ok}], History),
[{Pid, {rexi, kill_all, Args}, ok}] = History,
@@ -466,10 +466,10 @@ cleanup_called_on_timeout(_) ->
W1 = #shard{node = 'n1', ref = Ref1},
W2 = #shard{node = 'n2', ref = Ref2},
Workers = [W1, W2],
- meck:expect(rexi_utils, recv, fun(_, _, _, Acc, _, _) ->
+ ok = meck:expect(rexi_utils, recv, fun(_, _, _, Acc, _, _) ->
{timeout, Acc#stream_acc{workers = [{W2, waiting}]}}
end),
- meck:reset(fabric_util),
+ ok = meck:reset(fabric_util),
Res = start(Workers, #shard.ref, undefined, undefined, []),
?assertEqual({timeout, [W2]}, Res),
?assert(meck:called(fabric_util, cleanup, 1)).
@@ -480,10 +480,10 @@ cleanup_called_on_error(_) ->
W1 = #shard{node = 'n1', ref = Ref1},
W2 = #shard{node = 'n2', ref = Ref2},
Workers = [W1, W2],
- meck:expect(rexi_utils, recv, fun(_, _, _, _, _, _) ->
+ ok = meck:expect(rexi_utils, recv, fun(_, _, _, _, _, _) ->
{error, foo}
end),
- meck:reset(fabric_util),
+ ok = meck:reset(fabric_util),
Res = start(Workers, #shard.ref, undefined, undefined, []),
?assertEqual({error, foo}, Res),
?assert(meck:called(fabric_util, cleanup, 1)).
@@ -492,7 +492,7 @@ setup() ->
ok = meck:new(rexi_utils, [passthrough]),
ok = meck:new(config, [passthrough]),
ok = meck:new(fabric_util, [passthrough]),
- meck:expect(config, get, fun(_, _, Default) -> Default end),
+ ok = meck:expect(config, get, fun(_, _, Default) -> Default end),
ok = meck:expect(rexi, kill_all, fun(_) -> ok end),
% Speed up disconnect socket timeout for the test to 200 msec
ok = meck:expect(chttpd_util, mochiweb_client_req_check_msec, 0, 200).
diff --git a/src/fabric/src/fabric_view.erl b/src/fabric/src/fabric_view.erl
index 33a59db88..b3fbd4a53 100644
--- a/src/fabric/src/fabric_view.erl
+++ b/src/fabric/src/fabric_view.erl
@@ -565,7 +565,7 @@ mk_shard(Name, Range) ->
possibly_embed_doc_test_() ->
{
foreach,
- fun() -> meck:new(fabric) end,
+ fun() -> ok = meck:new(fabric) end,
fun(_) -> meck:unload() end,
[
?TDEF_FE(t_possibly_embed_doc_reduced),
@@ -638,7 +638,7 @@ t_possible_embed_doc_no_rev(_) ->
Row2 = {view_row, #{id => id, value => Value}},
Row3 = #view_row{id = id, value = Value, doc = EmbeddedDoc},
Row4 = {view_row, #{id => id, value => Value, doc => EmbeddedDoc}},
- meck:expect(fabric, open_doc, [DbName, Id, []], meck:val({ok, NewDoc})),
+ ok = meck:expect(fabric, open_doc, [DbName, Id, []], meck:val({ok, NewDoc})),
?assertEqual(Row3, possibly_embed_doc(State, Row1)),
?assertEqual(Row4, possibly_embed_doc(State, Row2)).
@@ -652,7 +652,7 @@ t_possible_embed_doc_no_rev_doc_not_found(_) ->
Row2 = {view_row, #{id => id, value => Value}},
Row3 = #view_row{id = id, value = Value, doc = null},
Row4 = {view_row, #{id => id, value => Value, doc => null}},
- meck:expect(fabric, open_doc, [DbName, Id, []], meck:val({not_found, undefined})),
+ ok = meck:expect(fabric, open_doc, [DbName, Id, []], meck:val({not_found, undefined})),
?assertEqual(Row3, possibly_embed_doc(State, Row1)),
?assertEqual(Row4, possibly_embed_doc(State, Row2)).
@@ -666,7 +666,7 @@ t_possible_embed_doc_no_rev_doc_error(_) ->
Row2 = {view_row, #{id => id, value => Value}},
Row3 = #view_row{id = id, value = Value, doc = {error, fabric_error}},
Row4 = {view_row, #{id => id, value => Value, doc => {error, fabric_error}}},
- meck:expect(fabric, open_doc, [DbName, Id, []], meck:val(fabric_error)),
+ ok = meck:expect(fabric, open_doc, [DbName, Id, []], meck:val(fabric_error)),
?assertEqual(Row3, possibly_embed_doc(State, Row1)),
?assertEqual(Row4, possibly_embed_doc(State, Row2)).
@@ -685,7 +685,12 @@ t_possible_embed_doc(_) ->
Row2 = {view_row, #{id => id, value => Value}},
Row3 = #view_row{id = id, value = Value, doc = EmbeddedDoc},
Row4 = {view_row, #{id => id, value => Value, doc => EmbeddedDoc}},
- meck:expect(fabric, open_revs, [DbName, Id, [ParsedRev], []], meck:val({ok, [{ok, NewDoc}]})),
+ ok = meck:expect(
+ fabric,
+ open_revs,
+ [DbName, Id, [ParsedRev], []],
+ meck:val({ok, [{ok, NewDoc}]})
+ ),
?assertEqual(Row3, possibly_embed_doc(State, Row1)),
?assertEqual(Row4, possibly_embed_doc(State, Row2)).
@@ -701,7 +706,7 @@ t_possible_embed_doc_not_found(_) ->
Row2 = {view_row, #{id => id, value => Value}},
Row3 = #view_row{id = id, value = Value, doc = null},
Row4 = {view_row, #{id => id, value => Value, doc => null}},
- meck:expect(
+ ok = meck:expect(
fabric,
open_revs,
[DbName, Id, [ParsedRev], []],
@@ -722,7 +727,7 @@ t_possible_embed_doc_error(_) ->
Row2 = {view_row, #{id => id, value => Value}},
Row3 = #view_row{id = id, value = Value, doc = {error, fabric_error}},
Row4 = {view_row, #{id => id, value => Value, doc => {error, fabric_error}}},
- meck:expect(fabric, open_revs, [DbName, Id, [ParsedRev], []], meck:val(fabric_error)),
+ ok = meck:expect(fabric, open_revs, [DbName, Id, [ParsedRev], []], meck:val(fabric_error)),
?assertEqual(Row3, possibly_embed_doc(State, Row1)),
?assertEqual(Row4, possibly_embed_doc(State, Row2)).
@@ -760,7 +765,7 @@ t_detach_partition_no_partition_map(_) ->
get_next_row_test_() ->
{
foreach,
- fun() -> meck:new([rexi, couch_query_servers]) end,
+ fun() -> ok = meck:new([rexi, couch_query_servers]) end,
fun(_) -> meck:unload() end,
[
?TDEF_FE(t_get_next_row_end),
@@ -782,7 +787,7 @@ t_get_next_row_map(_) ->
State1 = #collector{rows = [Row1 | Rest], counters = Counters1},
State2 = #collector{rows = [Row2 | Rest], counters = Counters1},
State3 = #collector{rows = Rest, counters = Counters2},
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
?assertEqual({Row1, State3}, get_next_row(State1)),
?assertEqual({Row2, State3}, get_next_row(State2)).
@@ -850,11 +855,14 @@ t_get_next_row_reduce(_) ->
},
Row1 = #view_row{key = Key, id = reduced, value = finalized},
Row2 = {view_row, #{key => Key, id => reduced, value => finalized}},
- meck:expect(rexi, stream_ack, ['_'], meck:val(ok)),
- meck:expect(
- couch_query_servers, rereduce, [Language, [reducer], Values], meck:val({ok, [reduced]})
+ ok = meck:expect(rexi, stream_ack, ['_'], meck:val(ok)),
+ ok = meck:expect(
+ couch_query_servers,
+ rereduce,
+ [Language, [reducer], Values],
+ meck:val({ok, [reduced]})
),
- meck:expect(couch_query_servers, finalize, [reducer, reduced], meck:val({ok, finalized})),
+ ok = meck:expect(couch_query_servers, finalize, [reducer, reduced], meck:val({ok, finalized})),
?assertEqual({Row1, State3}, get_next_row(State1)),
?assertEqual({Row2, State4}, get_next_row(State2)).
diff --git a/src/fabric/src/fabric_view_all_docs.erl b/src/fabric/src/fabric_view_all_docs.erl
index 2d0133acb..9eda1bf61 100644
--- a/src/fabric/src/fabric_view_all_docs.erl
+++ b/src/fabric/src/fabric_view_all_docs.erl
@@ -410,8 +410,8 @@ handle_message_test_() ->
{
foreach,
fun() ->
- meck:new(foo, [non_strict]),
- meck:new(fabric_view)
+ ok = meck:new(foo, [non_strict]),
+ ok = meck:new(fabric_view)
end,
fun(_) -> meck:unload() end,
[
@@ -427,13 +427,16 @@ handle_message_test_() ->
t_handle_message_rexi_down(_) ->
Message = {rexi_DOWN, undefined, {undefined, node}, undefined},
- meck:expect(fabric_view, check_down_shards, [state, node], meck:val(fabric_view_result)),
+ ok = meck:expect(fabric_view, check_down_shards, [state, node], meck:val(fabric_view_result)),
?assertEqual(fabric_view_result, handle_message(Message, source, state)).
t_handle_message_rexi_exit(_) ->
Message = {rexi_EXIT, reason},
- meck:expect(
- fabric_view, handle_worker_exit, [state, source, reason], meck:val(fabric_view_result)
+ ok = meck:expect(
+ fabric_view,
+ handle_worker_exit,
+ [state, source, reason],
+ meck:val(fabric_view_result)
),
?assertEqual(fabric_view_result, handle_message(Message, source, state)).
@@ -447,7 +450,7 @@ t_handle_message_meta_zero(_) ->
State2 = #collector{counters = Counters2, total_rows = 3, update_seq = nil, offset = 2},
State3 = #collector{counters = Counters1, total_rows = null, update_seq = null, offset = null},
State4 = #collector{counters = Counters2, total_rows = null, update_seq = null, offset = null},
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
?assertEqual({ok, State2}, handle_message({meta, Meta1}, Worker, State1)),
?assertEqual({ok, State4}, handle_message({meta, Meta2}, Worker, State3)).
@@ -513,13 +516,28 @@ t_handle_message_meta(_) ->
callback = fun foo:bar/2,
user_acc = updated_accumulator3
},
- meck:expect(fabric_view_changes, pack_seqs, [[{worker1, seq}]], meck:val(packed_seq)),
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
- meck:expect(foo, bar, [{meta, Meta2}, accumulator1], meck:val({go1, updated_accumulator1})),
+ ok = meck:expect(fabric_view_changes, pack_seqs, [[{worker1, seq}]], meck:val(packed_seq)),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(
+ foo,
+ bar,
+ [{meta, Meta2}, accumulator1],
+ meck:val({go1, updated_accumulator1})
+ ),
?assertEqual({go1, State4}, handle_message({meta, Meta1}, Worker, State1)),
- meck:expect(foo, bar, [{meta, Meta3}, accumulator2], meck:val({go2, updated_accumulator2})),
+ ok = meck:expect(
+ foo,
+ bar,
+ [{meta, Meta3}, accumulator2],
+ meck:val({go2, updated_accumulator2})
+ ),
?assertEqual({go2, State5}, handle_message({meta, Meta1}, Worker, State2)),
- meck:expect(foo, bar, [{meta, Meta4}, accumulator3], meck:val({go3, updated_accumulator3})),
+ ok = meck:expect(
+ foo,
+ bar,
+ [{meta, Meta4}, accumulator3],
+ meck:val({go3, updated_accumulator3})
+ ),
?assertEqual({go3, State6}, handle_message({meta, Meta4}, Worker, State3)).
t_handle_message_row(_) ->
@@ -544,9 +562,9 @@ t_handle_message_row(_) ->
State2 = #collector{query_args = QueryArgs2, counters = Counters1, rows = Rows2},
State3 = #collector{query_args = QueryArgs1, counters = Counters2, rows = Rows3},
State4 = #collector{query_args = QueryArgs2, counters = Counters2, rows = Rows4},
- meck:expect(fabric_view, maybe_send_row, [State3], meck:val(send_row1)),
+ ok = meck:expect(fabric_view, maybe_send_row, [State3], meck:val(send_row1)),
?assertEqual(send_row1, handle_message(Row1, Worker, State1)),
- meck:expect(fabric_view, maybe_send_row, [State4], meck:val(send_row2)),
+ ok = meck:expect(fabric_view, maybe_send_row, [State4], meck:val(send_row2)),
?assertEqual(send_row2, handle_message(Row2, Worker, State2)).
t_handle_message_complete(_) ->
@@ -555,14 +573,14 @@ t_handle_message_complete(_) ->
Counters2 = [{Worker, 7}],
State1 = #collector{counters = Counters1},
State2 = #collector{counters = Counters2},
- meck:expect(fabric_view, maybe_send_row, [State2], meck:val(maybe_row)),
+ ok = meck:expect(fabric_view, maybe_send_row, [State2], meck:val(maybe_row)),
?assertEqual(maybe_row, handle_message(complete, Worker, State1)).
t_handle_message_execution_stats(_) ->
Message = {execution_stats, stats},
Source = {worker, from},
- meck:expect(foo, bar, [Message, accumulator], meck:val({go, updated_accumulator})),
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(foo, bar, [Message, accumulator], meck:val({go, updated_accumulator})),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
State1 = #collector{callback = fun foo:bar/2, user_acc = accumulator},
State2 = #collector{callback = fun foo:bar/2, user_acc = updated_accumulator},
?assertEqual({go, State2}, handle_message(Message, Source, State1)).
@@ -570,7 +588,7 @@ t_handle_message_execution_stats(_) ->
open_doc_test_() ->
{
foreach,
- fun() -> meck:new(fabric) end,
+ fun() -> ok = meck:new(fabric) end,
fun(_) -> meck:unload() end,
[
?TDEF_FE(t_open_doc_not_found),
@@ -587,7 +605,7 @@ t_open_doc_not_found(_) ->
Options2 = [deleted],
Row1 = #view_row{key = id, doc = undefined},
Row2 = {view_row, #{key => id}},
- meck:expect(fabric, open_doc, [db, id, Options2], meck:val({not_found, missing})),
+ ok = meck:expect(fabric, open_doc, [db, id, Options2], meck:val({not_found, missing})),
{_, Ref1} = spawn_monitor(?MODULE, open_doc, [db, Options1, id, true, Extra1]),
receive
{'DOWN', Ref1, _, _, Result1} ->
@@ -609,7 +627,7 @@ t_open_doc_deleted(_) ->
Value = {[{rev, <<"1-foo">>}, {deleted, true}]},
Row1 = #view_row{key = id, id = id, value = Value, doc = null},
Row2 = {view_row, #{key => id, id => id, value => Value, doc => null}},
- meck:expect(fabric, open_doc, [db, id, Options2], meck:val({ok, Doc})),
+ ok = meck:expect(fabric, open_doc, [db, id, Options2], meck:val({ok, Doc})),
{_, Ref1} = spawn_monitor(?MODULE, open_doc, [db, Options1, id, true, Extra1]),
receive
{'DOWN', Ref1, _, _, Result1} ->
@@ -632,7 +650,7 @@ t_open_doc(_) ->
Value = {[{rev, <<"1-foo">>}]},
Row1 = #view_row{key = id, id = id, value = Value, doc = DocJson},
Row2 = {view_row, #{key => id, id => id, value => Value, doc => DocJson}},
- meck:expect(fabric, open_doc, [db, id, Options2], meck:val({ok, Doc})),
+ ok = meck:expect(fabric, open_doc, [db, id, Options2], meck:val({ok, Doc})),
{_, Ref1} = spawn_monitor(?MODULE, open_doc, [db, Options1, id, true, Extra1]),
receive
{'DOWN', Ref1, _, _, Result1} ->
@@ -649,8 +667,8 @@ t_open_doc_error(_) ->
Options1 = [],
Options2 = [deleted],
Exception = {id, reason},
- meck:expect(fabric, open_doc, [db, id, Options2], meck:raise(error, reason)),
- meck:expect(
+ ok = meck:expect(fabric, open_doc, [db, id, Options2], meck:raise(error, reason)),
+ ok = meck:expect(
couch_log,
error,
["_all_docs open error: ~s ~s :: ~w ~w", [db, id, {error, reason}, '_']],
@@ -666,8 +684,8 @@ doc_receive_loop_test_() ->
{
foreach,
fun() ->
- meck:new(foo, [non_strict]),
- meck:new(fabric_util)
+ ok = meck:new(foo, [non_strict]),
+ ok = meck:new(fabric_util)
end,
fun(_) -> meck:unload() end,
[
@@ -694,7 +712,7 @@ t_doc_receive_loop(_) ->
Props2 = {row, [{id, id2}, {key, key2}, {value, value2}]},
Row1 = #view_row{id = id1, key = key1, value = value1},
Row2 = {view_row, #{id => id2, key => key2, value => value2}},
- meck:expect(
+ ok = meck:expect(
foo,
spawned,
[
@@ -702,8 +720,8 @@ t_doc_receive_loop(_) ->
{[key2], meck:raise(exit, Row2)}
]
),
- meck:expect(foo, spawn, fun(K) -> spawn_monitor(foo, spawned, [K]) end),
- meck:expect(
+ ok = meck:expect(foo, spawn, fun(K) -> spawn_monitor(foo, spawned, [K]) end),
+ ok = meck:expect(
foo,
callback,
[
@@ -711,7 +729,7 @@ t_doc_receive_loop(_) ->
{[Props2, accumulator2], meck:val({stop, accumulator3})}
]
),
- meck:expect(fabric_util, all_docs_timeout, [], meck:val(1000)),
+ ok = meck:expect(fabric_util, all_docs_timeout, [], meck:val(1000)),
?assertEqual(
{ok, accumulator3},
doc_receive_loop(Keys, Pids, fun foo:spawn/1, MaxJobs, fun foo:callback/2, accumulator1)
@@ -721,10 +739,10 @@ t_doc_receive_loop_error(_) ->
Keys = [key1, key2, key3],
Pids = queue:from_list([]),
MaxJobs = 3,
- meck:expect(foo, spawned, [key1], meck:raise(exit, error)),
- meck:expect(foo, spawn, fun(K) -> spawn_monitor(foo, spawned, [K]) end),
- meck:expect(foo, callback, [{error, error}, accumulator1], meck:val({ok, accumulator2})),
- meck:expect(fabric_util, all_docs_timeout, [], meck:val(1000)),
+ ok = meck:expect(foo, spawned, [key1], meck:raise(exit, error)),
+ ok = meck:expect(foo, spawn, fun(K) -> spawn_monitor(foo, spawned, [K]) end),
+ ok = meck:expect(foo, callback, [{error, error}, accumulator1], meck:val({ok, accumulator2})),
+ ok = meck:expect(fabric_util, all_docs_timeout, [], meck:val(1000)),
?assertEqual(
{ok, accumulator2},
doc_receive_loop(Keys, Pids, fun foo:spawn/1, MaxJobs, fun foo:callback/2, accumulator1)
@@ -734,10 +752,10 @@ t_doc_receive_loop_timeout(_) ->
Keys = [key1, key2, key3],
Pids = queue:from_list([]),
MaxJobs = 3,
- meck:expect(foo, spawned, fun(key1) -> timer:sleep(infinity) end),
- meck:expect(foo, spawn, fun(K) -> spawn_monitor(foo, spawned, [K]) end),
- meck:expect(foo, callback, ['_', '_'], undefined),
- meck:expect(fabric_util, all_docs_timeout, [], meck:val(1)),
+ ok = meck:expect(foo, spawned, fun(key1) -> timer:sleep(infinity) end),
+ ok = meck:expect(foo, spawn, fun(K) -> spawn_monitor(foo, spawned, [K]) end),
+ ok = meck:expect(foo, callback, ['_', '_'], undefined),
+ ok = meck:expect(fabric_util, all_docs_timeout, [], meck:val(1)),
?assertEqual(
timeout,
doc_receive_loop(Keys, Pids, fun foo:spawn/1, MaxJobs, fun foo:callback/2, accumulator1)
diff --git a/src/fabric/src/fabric_view_changes.erl b/src/fabric/src/fabric_view_changes.erl
index 6bd571c0b..b109508f0 100644
--- a/src/fabric/src/fabric_view_changes.erl
+++ b/src/fabric/src/fabric_view_changes.erl
@@ -760,12 +760,11 @@ increment_changes_epoch() ->
-include_lib("couch/include/couch_eunit.hrl").
unpack_seq_setup() ->
- meck:new(mem3),
- meck:new(fabric_view),
- meck:expect(mem3, get_shard, fun(_, _, _) -> {ok, #shard{}} end),
- meck:expect(mem3, shards, fun(_) -> [#shard{}] end),
- meck:expect(fabric_ring, is_progress_possible, fun(_) -> true end),
- ok.
+ ok = meck:new(mem3),
+ ok = meck:new(fabric_view),
+ ok = meck:expect(mem3, get_shard, fun(_, _, _) -> {ok, #shard{}} end),
+ ok = meck:expect(mem3, shards, fun(_) -> [#shard{}] end),
+ ok = meck:expect(fabric_ring, is_progress_possible, fun(_) -> true end).
unpack_seqs_test_() ->
{
diff --git a/src/fabric/src/fabric_view_map.erl b/src/fabric/src/fabric_view_map.erl
index cc8ed6cf1..8c241c284 100644
--- a/src/fabric/src/fabric_view_map.erl
+++ b/src/fabric/src/fabric_view_map.erl
@@ -322,8 +322,8 @@ handle_message_test_() ->
{
foreach,
fun() ->
- meck:new(foo, [non_strict]),
- meck:new(fabric_view)
+ ok = meck:new(foo, [non_strict]),
+ ok = meck:new(fabric_view)
end,
fun(_) -> meck:unload() end,
[
@@ -343,13 +343,16 @@ handle_message_test_() ->
t_handle_message_rexi_down(_) ->
Message = {rexi_DOWN, undefined, {undefined, node}, undefined},
- meck:expect(fabric_view, check_down_shards, [state, node], meck:val(fabric_view_result)),
+ ok = meck:expect(fabric_view, check_down_shards, [state, node], meck:val(fabric_view_result)),
?assertEqual(fabric_view_result, handle_message(Message, source, state)).
t_handle_message_rexi_exit(_) ->
Message = {rexi_EXIT, reason},
- meck:expect(
- fabric_view, handle_worker_exit, [state, source, reason], meck:val(fabric_view_result)
+ ok = meck:expect(
+ fabric_view,
+ handle_worker_exit,
+ [state, source, reason],
+ meck:val(fabric_view_result)
),
?assertEqual(fabric_view_result, handle_message(Message, source, state)).
@@ -360,7 +363,7 @@ t_handle_message_meta_zero(_) ->
Counters2 = [{worker1, 1}, {worker2, 0}],
State1 = #collector{counters = Counters1, total_rows = 0, update_seq = nil, offset = 0},
State2 = #collector{counters = Counters2, total_rows = 3, update_seq = nil, offset = 2},
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
?assertEqual({ok, State2}, handle_message({meta, Meta}, Worker, State1)).
t_handle_message_meta(_) ->
@@ -406,7 +409,7 @@ t_handle_message_meta(_) ->
callback = fun foo:bar/2,
user_acc = updated_accumulator2
},
- meck:expect(
+ ok = meck:expect(
foo,
bar,
[
@@ -414,8 +417,8 @@ t_handle_message_meta(_) ->
{[{meta, Meta3}, accumulator2], meck:val({go2, updated_accumulator2})}
]
),
- meck:expect(fabric_view_changes, pack_seqs, [[{worker1, seq}]], meck:val(packed_seq)),
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(fabric_view_changes, pack_seqs, [[{worker1, seq}]], meck:val(packed_seq)),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
?assertEqual({go1, State3}, handle_message({meta, Meta1}, Worker, State1)),
?assertEqual({go2, State4}, handle_message({meta, Meta1}, Worker, State2)).
@@ -429,8 +432,8 @@ t_handle_message_limit(_) ->
Worker = {worker, from},
Row1 = #view_row{},
Row2 = {view_row, #{}},
- meck:expect(foo, bar, [complete, accumulator], meck:val({go, updated_accumulator})),
- meck:expect(rexi, stream_ack, [from], undefined),
+ ok = meck:expect(foo, bar, [complete, accumulator], meck:val({go, updated_accumulator})),
+ ok = meck:expect(rexi, stream_ack, [from], undefined),
?assertEqual({stop, State2}, handle_message(Row1, Worker, State1)),
?assertEqual({stop, State2}, handle_message(Row2, Worker, State1)),
?assertNot(meck:called(rexi, stream_ack, '_')).
@@ -446,8 +449,8 @@ t_handle_message_non_sorted(_) ->
Row1 = #view_row{id = id, key = key, doc = doc},
Row2 = {view_row, #{id => id, key => key, doc => doc}},
Props = {row, [{id, id}, {key, key}, {value, undefined}, {doc, doc}]},
- meck:expect(foo, bar, [Props, accumulator], meck:val({go, updated_accumulator})),
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(foo, bar, [Props, accumulator], meck:val({go, updated_accumulator})),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
?assertEqual({go, State2}, handle_message(Row1, Worker, State1)),
?assertEqual({go, State2}, handle_message(Row2, Worker, State1)).
@@ -509,8 +512,8 @@ t_handle_message_sorted(_) ->
rows = Rows4,
collation = <<"raw">>
},
- meck:expect(foo, bar, [Props, accumulator], meck:val({go, updated_accumulator})),
- meck:expect(
+ ok = meck:expect(foo, bar, [Props, accumulator], meck:val({go, updated_accumulator})),
+ ok = meck:expect(
fabric_view,
maybe_send_row,
[
@@ -527,14 +530,14 @@ t_handle_message_complete(_) ->
Counters2 = [{Worker, 7}],
State1 = #collector{counters = Counters1},
State2 = #collector{counters = Counters2},
- meck:expect(fabric_view, maybe_send_row, [State2], meck:val(maybe_row)),
+ ok = meck:expect(fabric_view, maybe_send_row, [State2], meck:val(maybe_row)),
?assertEqual(maybe_row, handle_message(complete, Worker, State1)).
t_handle_message_execution_stats(_) ->
Message = {execution_stats, stats},
Source = {worker, from},
- meck:expect(foo, bar, [Message, accumulator], meck:val({go, updated_accumulator})),
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(foo, bar, [Message, accumulator], meck:val({go, updated_accumulator})),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
State1 = #collector{callback = fun foo:bar/2, user_acc = accumulator},
State2 = #collector{callback = fun foo:bar/2, user_acc = updated_accumulator},
?assertEqual({go, State2}, handle_message(Message, Source, State1)).
diff --git a/src/fabric/src/fabric_view_reduce.erl b/src/fabric/src/fabric_view_reduce.erl
index 3206d01a4..c513d70f2 100644
--- a/src/fabric/src/fabric_view_reduce.erl
+++ b/src/fabric/src/fabric_view_reduce.erl
@@ -191,8 +191,8 @@ handle_message_test_() ->
{
foreach,
fun() ->
- meck:new(foo, [non_strict]),
- meck:new(fabric_view)
+ ok = meck:new(foo, [non_strict]),
+ ok = meck:new(fabric_view)
end,
fun(_) -> meck:unload() end,
[
@@ -209,13 +209,16 @@ handle_message_test_() ->
t_handle_message_rexi_down(_) ->
Message = {rexi_DOWN, undefined, {undefined, node}, undefined},
- meck:expect(fabric_view, check_down_shards, [state, node], meck:val(fabric_view_result)),
+ ok = meck:expect(fabric_view, check_down_shards, [state, node], meck:val(fabric_view_result)),
?assertEqual(fabric_view_result, handle_message(Message, source, state)).
t_handle_message_rexi_exit(_) ->
Message = {rexi_EXIT, reason},
- meck:expect(
- fabric_view, handle_worker_exit, [state, source, reason], meck:val(fabric_view_result)
+ ok = meck:expect(
+ fabric_view,
+ handle_worker_exit,
+ [state, source, reason],
+ meck:val(fabric_view_result)
),
?assertEqual(fabric_view_result, handle_message(Message, source, state)).
@@ -226,7 +229,7 @@ t_handle_message_meta_zero(_) ->
Counters2 = [{worker1, 1}, {worker2, 0}],
State1 = #collector{counters = Counters1, update_seq = nil},
State2 = #collector{counters = Counters2, update_seq = nil},
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
?assertEqual({ok, State2}, handle_message({meta, Meta}, Worker, State1)).
t_handle_message_meta(_) ->
@@ -260,7 +263,7 @@ t_handle_message_meta(_) ->
callback = fun foo:bar/2,
user_acc = updated_accumulator2
},
- meck:expect(
+ ok = meck:expect(
foo,
bar,
[
@@ -268,8 +271,8 @@ t_handle_message_meta(_) ->
{[{meta, Meta3}, accumulator2], meck:val({go2, updated_accumulator2})}
]
),
- meck:expect(fabric_view_changes, pack_seqs, [[{worker1, seq}]], meck:val(packed_seq)),
- meck:expect(rexi, stream_ack, [from], meck:val(ok)),
+ ok = meck:expect(fabric_view_changes, pack_seqs, [[{worker1, seq}]], meck:val(packed_seq)),
+ ok = meck:expect(rexi, stream_ack, [from], meck:val(ok)),
?assertEqual({go1, State3}, handle_message({meta, Meta1}, Worker, State1)),
?assertEqual({go2, State4}, handle_message({meta, Meta1}, Worker, State2)).
@@ -289,7 +292,7 @@ t_handle_message_row(_) ->
State2 = #collector{counters = Counters1, rows = Rows2},
State3 = #collector{counters = Counters2, rows = Rows3},
State4 = #collector{counters = Counters2, rows = Rows4},
- meck:expect(fabric_view, maybe_send_row, [
+ ok = meck:expect(fabric_view, maybe_send_row, [
{[State3], meck:val(maybe_row1)}, {[State4], meck:val(maybe_row2)}
]),
?assertEqual(maybe_row1, handle_message(Row1, Worker, State1)),
@@ -301,7 +304,7 @@ t_handle_message_complete(_) ->
Counters2 = [{Worker, 7}],
State1 = #collector{counters = Counters1},
State2 = #collector{counters = Counters2},
- meck:expect(fabric_view, maybe_send_row, [State2], meck:val(maybe_row)),
+ ok = meck:expect(fabric_view, maybe_send_row, [State2], meck:val(maybe_row)),
?assertEqual(maybe_row, handle_message(complete, Worker, State1)).
t_handle_message_ddoc_updated(_) ->
diff --git a/src/fabric/test/eunit/fabric_db_create_tests.erl b/src/fabric/test/eunit/fabric_db_create_tests.erl
index 9d78d177d..894786745 100644
--- a/src/fabric/test/eunit/fabric_db_create_tests.erl
+++ b/src/fabric/test/eunit/fabric_db_create_tests.erl
@@ -26,19 +26,20 @@ main_test_() ->
}.
setup() ->
- test_util:start_couch([fabric]).
+ Ctx = test_util:start_couch([fabric]),
+ ok = meck:new(mem3, [passthrough]),
+ ok = meck:new(fabric_util, [passthrough]),
+ Ctx.
teardown(Ctx) ->
+ meck:unload(),
test_util:stop_couch(Ctx).
t_handle_shard_doc_conflict(_) ->
DbName = ?tempdb(),
- meck:new(mem3, [passthrough]),
- meck:new(fabric_util, [passthrough]),
ok = meck:sequence(mem3, shards, 1, [
fun(_) -> meck:raise(error, database_does_not_exist) end,
[#shard{dbname = DbName}]
]),
- meck:expect(fabric_util, recv, 4, {error, conflict}),
- ?assertEqual({error, file_exists}, fabric_db_create:go(DbName, [])),
- meck:unload().
+ ok = meck:expect(fabric_util, recv, 4, {error, conflict}),
+ ?assertEqual({error, file_exists}, fabric_db_create:go(DbName, [])).
diff --git a/src/fabric/test/eunit/fabric_db_info_tests.erl b/src/fabric/test/eunit/fabric_db_info_tests.erl
index 57313df50..e7df560a1 100644
--- a/src/fabric/test/eunit/fabric_db_info_tests.erl
+++ b/src/fabric/test/eunit/fabric_db_info_tests.erl
@@ -28,7 +28,6 @@ setup() ->
test_util:start_couch([fabric]).
teardown(Ctx) ->
- meck:unload(),
test_util:stop_couch(Ctx).
t_update_seq_has_uuids(_) ->
diff --git a/src/fabric/test/eunit/fabric_db_uuids_tests.erl b/src/fabric/test/eunit/fabric_db_uuids_tests.erl
index 1042c7cd3..b406fb957 100644
--- a/src/fabric/test/eunit/fabric_db_uuids_tests.erl
+++ b/src/fabric/test/eunit/fabric_db_uuids_tests.erl
@@ -29,7 +29,6 @@ setup() ->
test_util:start_couch([fabric]).
teardown(Ctx) ->
- meck:unload(),
test_util:stop_couch(Ctx).
t_can_get_shard_uuids(_) ->
diff --git a/src/fabric/test/eunit/fabric_moved_shards_seq_tests.erl b/src/fabric/test/eunit/fabric_moved_shards_seq_tests.erl
index c3bb0c880..b296da5c7 100644
--- a/src/fabric/test/eunit/fabric_moved_shards_seq_tests.erl
+++ b/src/fabric/test/eunit/fabric_moved_shards_seq_tests.erl
@@ -104,5 +104,5 @@ seq_encode(Unpacked) ->
mock_epochs(Epochs) ->
% Since we made up a node name we'll have to mock epoch checking
- meck:new(couch_db_engine, [passthrough]),
- meck:expect(couch_db_engine, get_epochs, fun(_) -> Epochs end).
+ ok = meck:new(couch_db_engine, [passthrough]),
+ ok = meck:expect(couch_db_engine, get_epochs, fun(_) -> Epochs end).
diff --git a/src/fabric/test/eunit/fabric_open_revs_test.erl b/src/fabric/test/eunit/fabric_open_revs_test.erl
index 68df30ce4..c9cc203b4 100644
--- a/src/fabric/test/eunit/fabric_open_revs_test.erl
+++ b/src/fabric/test/eunit/fabric_open_revs_test.erl
@@ -194,12 +194,12 @@ t_two_revs_single_doc_latest({_, DbName}) ->
t_timeout_rexi_error({_, DbName}) ->
IdRevsOpts = {{<<"a">>, [{2, <<"x">>}]}, []},
- meck:new(rexi_utils, [passthrough]),
- meck:new(rexi, [passthrough]),
+ ok = meck:new(rexi_utils, [passthrough]),
+ ok = meck:new(rexi, [passthrough]),
RecFun = fun(_Refs, _KeyPos, _Fun, St, _Timeout, _PerMsgTO) ->
{timeout, St}
end,
- meck:expect(rexi_utils, recv, RecFun),
+ ok = meck:expect(rexi_utils, recv, RecFun),
?assertEqual({error, timeout}, fabric:open_revs(DbName, [IdRevsOpts], [])),
% Also check that workers were cleaned up properly
?assertEqual(1, meck:num_calls(rexi, kill_all, 1)).
diff --git a/src/fabric/test/eunit/fabric_tests.erl b/src/fabric/test/eunit/fabric_tests.erl
index 0b3f20a46..3b5650893 100644
--- a/src/fabric/test/eunit/fabric_tests.erl
+++ b/src/fabric/test/eunit/fabric_tests.erl
@@ -42,6 +42,7 @@ setup() ->
{Ctx, DbName}.
teardown({Ctx, DbName}) ->
+ meck:unload(),
fabric:delete_db(DbName),
test_util:stop_couch(Ctx).
@@ -259,8 +260,11 @@ t_design_docs_configuration(_) ->
include_docs = true,
extra = [{namespace, <<"_design">>}, {view_row_map, true}]
},
- meck:expect(
- fabric, all_docs, [DbName, AdminCtx, '_', [], QueryArgs], meck:val(all_docs_result)
+ ok = meck:expect(
+ fabric,
+ all_docs,
+ [DbName, AdminCtx, '_', [], QueryArgs],
+ meck:val(all_docs_result)
),
?assertEqual(all_docs_result, fabric:design_docs(DbName)).
@@ -272,8 +276,11 @@ t_design_docs_configuration_io_priority(_) ->
include_docs = true,
extra = [{namespace, <<"_design">>}, {io_priority, io_priority}, {view_row_map, true}]
},
- meck:expect(
- fabric, all_docs, [DbName, AdminCtx, '_', [], QueryArgs], meck:val(all_docs_result)
+ ok = meck:expect(
+ fabric,
+ all_docs,
+ [DbName, AdminCtx, '_', [], QueryArgs],
+ meck:val(all_docs_result)
),
put(io_priority, io_priority),
?assertEqual(all_docs_result, fabric:design_docs(DbName)).
@@ -301,7 +308,12 @@ t_query_view_configuration({_Ctx, DbName}) ->
Options = [],
Accumulator = [],
Parameters = [DbName, Options, '_', ViewName, QueryArgs, '_', Accumulator, '_'],
- meck:expect(fabric_view_map, go, Parameters, meck:val(fabric_view_map_results)),
+ ok = meck:expect(
+ fabric_view_map,
+ go,
+ Parameters,
+ meck:val(fabric_view_map_results)
+ ),
?assertEqual(fabric_view_map_results, fabric:query_view(DbName, DDocName, ViewName)).
fabric_all_dbs_test_() ->