summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Doane <jaydoane@apache.org>2021-10-26 22:28:52 -0700
committerJay Doane <jay.s.doane@gmail.com>2021-10-27 11:22:47 -0700
commitc119ac72ce151676d0bbc95abe199b16f0df9a79 (patch)
tree8540635fcb04433f5aa70fb7c34ce65cfa309313
parent537fd31185142190ff3dc55d707f9d899b455b17 (diff)
downloadcouchdb-c119ac72ce151676d0bbc95abe199b16f0df9a79.tar.gz
Mock `couch_log:warning/2`
Prevent failures like: mem3_rep: find_source_seq_unknown_node_test...*failed* in function gen_server:call/2 (gen_server.erl, line 206) in call from couch_log:log/3 (src/couch_log.erl, line 73) in call from mem3_rep:find_source_seq_int/5 (src/mem3_rep.erl, line 248) in call from mem3_rep:'-find_source_seq_unknown_node_test/0-fun-0-'/0 (src/mem3_rep.erl, line 794) **exit:{noproc,{gen_server,call, [couch_log_server, {log,{log_entry,warning,<0.17426.5>, ["mem3_rep",32,102,105,110,100|...], "--------", ["2021",45,"10",45|...]}}]}} output:<<"">>
-rw-r--r--src/mem3/src/mem3_rep.erl27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 7fa0fc027..2487e6a98 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -788,36 +788,53 @@ reset_remaining(#{} = Targets) ->
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
+-define(TDEF(A), {atom_to_list(A), fun A/0}).
-find_source_seq_unknown_node_test() ->
+
+find_source_seq_int_test_() ->
+ {
+ setup,
+ fun() -> meck:expect(couch_log, warning, 2, ok) end,
+ fun(_) -> meck:unload() end,
+ [
+ ?TDEF(t_unknown_node),
+ ?TDEF(t_unknown_uuid),
+ ?TDEF(t_ok),
+ ?TDEF(t_old_ok),
+ ?TDEF(t_different_node)
+ ]
+ }.
+
+
+t_unknown_node() ->
?assertEqual(
find_source_seq_int(doc_(), <<"foo">>, <<"bing">>, <<"bar_uuid">>, 10),
0
).
-find_source_seq_unknown_uuid_test() ->
+t_unknown_uuid() ->
?assertEqual(
find_source_seq_int(doc_(), <<"foo">>, <<"bar">>, <<"teapot">>, 10),
0
).
-find_source_seq_ok_test() ->
+t_ok() ->
?assertEqual(
find_source_seq_int(doc_(), <<"foo">>, <<"bar">>, <<"bar_uuid">>, 100),
100
).
-find_source_seq_old_ok_test() ->
+t_old_ok() ->
?assertEqual(
find_source_seq_int(doc_(), <<"foo">>, <<"bar">>, <<"bar_uuid">>, 84),
50
).
-find_source_seq_different_node_test() ->
+t_different_node() ->
?assertEqual(
find_source_seq_int(doc_(), <<"foo2">>, <<"bar">>, <<"bar_uuid">>, 92),
31