iilyak commented on code in PR #4151:
URL: https://github.com/apache/couchdb/pull/4151#discussion_r950293536


##########
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 wish eunit have assert macro with comment. I bet the error message would 
be hard to understand when we hit this particular assertion. 
   
   I am going to simulate the failure to see whether error message contains 
enough info to point to a failing test.



-- 
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]

Reply via email to