iilyak commented on code in PR #4151:
URL: https://github.com/apache/couchdb/pull/4151#discussion_r950306413
##########
src/couch_replicator/test/eunit/couch_replicator_use_checkpoints_tests.erl:
##########
@@ -14,133 +14,77 @@
-include_lib("couch/include/couch_eunit.hrl").
-include_lib("couch/include/couch_db.hrl").
-
--import(couch_replicator_test_helper, [
- db_url/1,
- replicate/1
-]).
+-include("couch_replicator_test.hrl").
-define(DOCS_COUNT, 100).
-define(TIMEOUT_EUNIT, 30).
-define(i2l(I), integer_to_list(I)).
-define(io2b(Io), iolist_to_binary(Io)).
-start(false) ->
- fun
- ({finished, _, {CheckpointHistory}}) ->
- ?assertEqual([{<<"use_checkpoints">>, false}], CheckpointHistory);
- (_) ->
- ok
- end;
-start(true) ->
- fun
- ({finished, _, {CheckpointHistory}}) ->
- ?assertNotEqual(
- false,
- lists:keyfind(
- <<"session_id">>,
- 1,
- CheckpointHistory
- )
- );
- (_) ->
- ok
- end.
-
-stop(_, _) ->
- ok.
-
-setup() ->
- DbName = ?tempdb(),
- {ok, Db} = couch_db:create(DbName, [?ADMIN_CTX]),
- ok = couch_db:close(Db),
- DbName.
+setup_checkpoints() ->
+ {Ctx, {Source, Target}} = couch_replicator_test_helper:test_setup(),
+ Fun = fun notifier_checkpoint_fun/1,
+ {ok, Listener} = couch_replicator_notifier:start_link(Fun),
+ {Ctx, {Source, Target, Listener}}.
-setup(remote) ->
- {remote, setup()};
-setup({_, Fun, {A, B}}) ->
- Ctx = test_util:start_couch([couch_replicator]),
+setup_no_checkpoints() ->
+ {Ctx, {Source, Target}} = couch_replicator_test_helper:test_setup(),
+ Fun = fun notifier_no_checkpoint_fun/1,
{ok, Listener} = couch_replicator_notifier:start_link(Fun),
- Source = setup(A),
- Target = setup(B),
{Ctx, {Source, Target, Listener}}.
-teardown({remote, DbName}) ->
- teardown(DbName);
-teardown(DbName) ->
- ok = couch_server:delete(DbName, [?ADMIN_CTX]),
- ok.
+teardown({Ctx, {Source, Target, Listener}}) ->
+ couch_replicator_notifier:stop(Listener),
+ couch_replicator_test_helper:test_teardown({Ctx, {Source, Target}}).
-teardown(_, {Ctx, {Source, Target, Listener}}) ->
- teardown(Source),
- teardown(Target),
+notifier_checkpoint_fun({finished, _, {CheckpointHistory}}) ->
+ SId = lists:keyfind(<<"session_id">>, 1, CheckpointHistory),
+ ?assertNotEqual(false, SId);
Review Comment:
I flipped the condition:
```diff
---
a/src/couch_replicator/test/eunit/couch_replicator_use_checkpoints_tests.erl
+++
b/src/couch_replicator/test/eunit/couch_replicator_use_checkpoints_tests.erl
@@ -39,7 +39,7 @@ teardown({Ctx, {Source, Target, Listener}}) ->
notifier_checkpoint_fun({finished, _, {CheckpointHistory}}) ->
SId = lists:keyfind(<<"session_id">>, 1, CheckpointHistory),
- ?assertNotEqual(false, SId);
+ ?assertEqual(false, SId);
notifier_checkpoint_fun(_) ->
ok.
```
The error I get is
```erlang
❯ make eunit apps=couch_replicator
suites=couch_replicator_use_checkpoints_tests
==> couch_replicator (compile)
==> rel (compile)
==> couchdb (compile)
WARN: Missing plugins: [pc]
WARN: Missing plugins: [covertool]
==> couchdb (setup_eunit)
==> couch_replicator (eunit)
Compiled test/eunit/couch_replicator_use_checkpoints_tests.erl
======================== EUnit ========================
module 'couch_replicator_use_checkpoints_tests'
Replication test using checkpoints
couch_replicator_use_checkpoints_tests:59:
-use_checkpoints_test_/0-fun-0- (use_checkpoints)...*skipped*
undefined
*unexpected termination of test process*
::{'EXIT',
{{assertEqual,
[{module,couch_replicator_use_checkpoints_tests},
{line,42},
{expression,"SId"},
{expected,false},
{value,{<<"session_id">>,<<"8a7c0fef54abfc03c90f"...>>}}]},
[{couch_replicator_use_checkpoints_tests,notifier_checkpoint_fun,1,
[{file,"test/eunit/couch_replicator_use_checkpoints_tests.erl"},
{line,42}]},
{couch_replicator_notifier,handle_event,2,
[{file,"src/couch_replicator_notifier.erl"},{line,47}]},
{gen_event,server_update,4,[{file,"gen_event.erl"},{line,793}]},
{gen_event,server_notify,4,[{file,"gen_event.erl"},{line,775}]},
{gen_event,handle_msg,6,[{file,"gen_event.erl"},{line,517}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}
=======================================================
Failed: 0. Skipped: 0. Passed: 0.
One or more tests were cancelled.
ERROR: One or more eunit tests failed.
ERROR: eunit failed while processing
/Users/iilyak/Code/couchdb/src/couch_replicator: rebar_abort
make: *** [eunit] Error 1
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]