eiri commented on a change in pull request #560: Fix broken eunit test in 
changes_since_test_ test suite
URL: https://github.com/apache/couchdb/pull/560#discussion_r120679049
 
 

 ##########
 File path: src/couch_mrview/test/couch_mrview_changes_since_tests.erl
 ##########
 @@ -92,37 +129,37 @@ test_basic_since(Db) ->
     ]},
     ?_assertEqual(Result, Expect).
 
-test_range_since(Db) ->
+test_range_since(_, Db) ->
     Result = run_query(Db, 5, [{start_key, 3}, {end_key, 5}]),
     Expect = {ok, [
                 {{6, 4, <<"4">>}, 4},
                 {{7, 5, <<"5">>}, 5}
     ]},
     ?_assertEqual(Result, Expect).
 
-test_basic_count(Db) ->
+test_basic_count(_, Db) ->
     Result = run_count_query(Db, 0, []),
     ?_assertEqual(Result, 10).
 
-test_range_count(Db) ->
+test_range_count(_, Db) ->
     Result = run_count_query(Db, 0, [{start_key, 3}, {end_key, 5}]),
     ?_assertEqual(Result, 3).
 
-test_basic_count_since(Db) ->
+test_basic_count_since(_, Db) ->
     Result = run_count_query(Db, 5, []),
     ?_assertEqual(Result, 6).
 
-test_range_count_since(Db) ->
+test_range_count_since(_, Db) ->
     Result = run_count_query(Db, 5, [{start_key, 3}, {end_key, 5}]),
     ?_assertEqual(Result, 2).
 
-test_compact(Db) ->
+test_compact(_, Db) ->
     Result = couch_mrview:compact(Db, <<"_design/bar">>),
     ?_assertEqual(Result, ok),
 
 Review comment:
   There are for warnings for all those tests that looks like "Warning: a term 
is constructed, but never used". I'll explain what's wrong taking this line as 
an example.
   
   In erlang unit tests all the macros starting with underscore not executed 
immediately, but instead return function wrapping the assertion. Function 
`test_compact` here is what called generator and it supposed to return either 
function to execute as a test or list of such function. We are returning test 
function generated with last line `?_assertEqual(Count, 10)`, so it got tested.
   
   But call `?_assertEqual(Result, ok)` is not actually testing anything, it 
returns function that we are throwing away and this is what the warning about - 
we are constructing a function, but never use it. To fix it we need to return 
list of tests, like this: `[?_assertEqual(Result, ok), ?_assertEqual(Count, 
10)]`
   
   There are four such places in this test module, please fix all of them.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to