Suppress unused function compiler warnings
authorJay Doane <jay.s.doane@gmail.com>
Thu, 13 Dec 2018 03:49:01 +0000 (19:49 -0800)
committerJay Doane <jay.s.doane@gmail.com>
Thu, 27 Dec 2018 21:07:57 +0000 (13:07 -0800)
- Add unused test cases to test fixture
- Eliminate unreferenced code
- Comment out code that is referenced in commented code only

src/couch/test/couch_changes_tests.erl
src/couch/test/couch_doc_json_tests.erl
src/couch/test/couch_flags_tests.erl
src/couch/test/couchdb_vhosts_tests.erl

index e4ea761..0c2f5f9 100644 (file)
@@ -122,17 +122,17 @@ filter_by_design() ->
         }
     }.
 
-filter_by_custom_function() ->
-    {
-        "Filter function",
-        {
-            foreach,
-            fun setup/0, fun teardown/1,
-            [
-                fun should_receive_heartbeats/1
-            ]
-        }
-    }.
+%% filter_by_custom_function() ->
+%%     {
+%%         "Filter function",
+%%         {
+%%             foreach,
+%%             fun setup/0, fun teardown/1,
+%%             [
+%%                 fun should_receive_heartbeats/1
+%%             ]
+%%         }
+%%     }.
 
 filter_by_filter_function() ->
     {
@@ -547,72 +547,72 @@ should_emit_only_design_documents({DbName, Revs}) ->
                           Rows2)
         end).
 
-should_receive_heartbeats(_) ->
-    {timeout, ?TEST_TIMEOUT div 1000,
-     ?_test(
-         begin
-             DbName = ?tempdb(),
-             Timeout = 100,
-             {ok, Db} = create_db(DbName),
-
-             {ok, _} = save_doc(Db, {[
-                 {<<"_id">>, <<"_design/filtered">>},
-                 {<<"language">>, <<"javascript">>},
-                     {<<"filters">>, {[
-                         {<<"foo">>, <<"function(doc) {
-                             return ['doc10', 'doc11', 'doc12'].indexOf(doc._id) != -1;}">>
-                     }]}}
-             ]}),
-
-             ChangesArgs = #changes_args{
-                 filter = "filtered/foo",
-                 feed = "continuous",
-                 timeout = 10000,
-                 heartbeat = 1000
-             },
-             Consumer = spawn_consumer(DbName, ChangesArgs, {json_req, null}),
-
-             {ok, _Rev1} = save_doc(Db, {[{<<"_id">>, <<"doc1">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev2} = save_doc(Db, {[{<<"_id">>, <<"doc2">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev3} = save_doc(Db, {[{<<"_id">>, <<"doc3">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev4} = save_doc(Db, {[{<<"_id">>, <<"doc4">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev5} = save_doc(Db, {[{<<"_id">>, <<"doc5">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev6} = save_doc(Db, {[{<<"_id">>, <<"doc6">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev7} = save_doc(Db, {[{<<"_id">>, <<"doc7">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev8} = save_doc(Db, {[{<<"_id">>, <<"doc8">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev9} = save_doc(Db, {[{<<"_id">>, <<"doc9">>}]}),
-
-             Heartbeats = get_heartbeats(Consumer),
-             ?assert(Heartbeats > 0),
-
-             {ok, _Rev10} = save_doc(Db, {[{<<"_id">>, <<"doc10">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev11} = save_doc(Db, {[{<<"_id">>, <<"doc11">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev12} = save_doc(Db, {[{<<"_id">>, <<"doc12">>}]}),
-
-             Heartbeats2 = get_heartbeats(Consumer),
-             ?assert(Heartbeats2 > Heartbeats),
-
-             Rows = get_rows(Consumer),
-             ?assertEqual(3, length(Rows)),
-
-             {ok, _Rev13} = save_doc(Db, {[{<<"_id">>, <<"doc13">>}]}),
-             timer:sleep(Timeout),
-             {ok, _Rev14} = save_doc(Db, {[{<<"_id">>, <<"doc14">>}]}),
-             timer:sleep(Timeout),
-
-             Heartbeats3 = get_heartbeats(Consumer),
-             ?assert(Heartbeats3 > Heartbeats2)
-        end)}.
+%% should_receive_heartbeats(_) ->
+%%     {timeout, ?TEST_TIMEOUT div 1000,
+%%      ?_test(
+%%          begin
+%%              DbName = ?tempdb(),
+%%              Timeout = 100,
+%%              {ok, Db} = create_db(DbName),
+
+%%              {ok, _} = save_doc(Db, {[
+%%                  {<<"_id">>, <<"_design/filtered">>},
+%%                  {<<"language">>, <<"javascript">>},
+%%                      {<<"filters">>, {[
+%%                          {<<"foo">>, <<"function(doc) {
+%%                              return ['doc10', 'doc11', 'doc12'].indexOf(doc._id) != -1;}">>
+%%                      }]}}
+%%              ]}),
+
+%%              ChangesArgs = #changes_args{
+%%                  filter = "filtered/foo",
+%%                  feed = "continuous",
+%%                  timeout = 10000,
+%%                  heartbeat = 1000
+%%              },
+%%              Consumer = spawn_consumer(DbName, ChangesArgs, {json_req, null}),
+
+%%              {ok, _Rev1} = save_doc(Db, {[{<<"_id">>, <<"doc1">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev2} = save_doc(Db, {[{<<"_id">>, <<"doc2">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev3} = save_doc(Db, {[{<<"_id">>, <<"doc3">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev4} = save_doc(Db, {[{<<"_id">>, <<"doc4">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev5} = save_doc(Db, {[{<<"_id">>, <<"doc5">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev6} = save_doc(Db, {[{<<"_id">>, <<"doc6">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev7} = save_doc(Db, {[{<<"_id">>, <<"doc7">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev8} = save_doc(Db, {[{<<"_id">>, <<"doc8">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev9} = save_doc(Db, {[{<<"_id">>, <<"doc9">>}]}),
+
+%%              Heartbeats = get_heartbeats(Consumer),
+%%              ?assert(Heartbeats > 0),
+
+%%              {ok, _Rev10} = save_doc(Db, {[{<<"_id">>, <<"doc10">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev11} = save_doc(Db, {[{<<"_id">>, <<"doc11">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev12} = save_doc(Db, {[{<<"_id">>, <<"doc12">>}]}),
+
+%%              Heartbeats2 = get_heartbeats(Consumer),
+%%              ?assert(Heartbeats2 > Heartbeats),
+
+%%              Rows = get_rows(Consumer),
+%%              ?assertEqual(3, length(Rows)),
+
+%%              {ok, _Rev13} = save_doc(Db, {[{<<"_id">>, <<"doc13">>}]}),
+%%              timer:sleep(Timeout),
+%%              {ok, _Rev14} = save_doc(Db, {[{<<"_id">>, <<"doc14">>}]}),
+%%              timer:sleep(Timeout),
+
+%%              Heartbeats3 = get_heartbeats(Consumer),
+%%              ?assert(Heartbeats3 > Heartbeats2)
+%%         end)}.
 
 should_filter_by_doc_attribute({DbName, _}) ->
     ?_test(
@@ -800,17 +800,17 @@ get_rows({Consumer, _}) ->
     ?assertNotEqual(timeout, Resp),
     Resp.
 
-get_heartbeats({Consumer, _}) ->
-    Ref = make_ref(),
-    Consumer ! {get_heartbeats, Ref},
-    Resp = receive
-        {hearthbeats, Ref, HeartBeats} ->
-            HeartBeats
-    after ?TIMEOUT ->
-        timeout
-    end,
-    ?assertNotEqual(timeout, Resp),
-    Resp.
+%% get_heartbeats({Consumer, _}) ->
+%%     Ref = make_ref(),
+%%     Consumer ! {get_heartbeats, Ref},
+%%     Resp = receive
+%%         {hearthbeats, Ref, HeartBeats} ->
+%%             HeartBeats
+%%     after ?TIMEOUT ->
+%%         timeout
+%%     end,
+%%     ?assertNotEqual(timeout, Resp),
+%%     Resp.
 
 clear_rows({Consumer, _}) ->
     Ref = make_ref(),
index bcff064..cc5dc32 100644 (file)
@@ -51,6 +51,8 @@ json_doc_test_() ->
         fun setup/0, fun teardown/1,
         fun(_) ->
             [{"Document from JSON", [
+                from_json_with_dbname_error_cases(),
+                from_json_with_db_name_success_cases(),
                 from_json_success_cases(),
                 from_json_error_cases()
              ]},
index a467265..cda7639 100644 (file)
@@ -124,14 +124,14 @@ is_enabled() ->
             ?_assertNot(couch_flags:is_enabled(non_existent, "shards/blacklist/4"))}
     ]}].
 
-match_performance() ->
-    [{"match_performance", [
-        ?_test(begin
-            ?debugTime("1 million of operations took", lists:foreach(fun(_) ->
-                couch_flags:is_enabled(bar, "shards/test/exact")
-            end, lists:seq(1, 1000000)))
-        end)
-    ]}].
+%% match_performance() ->
+%%     [{"match_performance", [
+%%         ?_test(begin
+%%             ?debugTime("1 million of operations took", lists:foreach(fun(_) ->
+%%                 couch_flags:is_enabled(bar, "shards/test/exact")
+%%             end, lists:seq(1, 1000000)))
+%%         end)
+%%     ]}].
 
 
 test_config() ->
index 2562a06..1c41172 100644 (file)
@@ -270,7 +270,3 @@ should_return_path_for_vhost_with_wildcard_host({Url, DbName}) ->
                               {reason, ?iofmt("Request failed: ~p", [Else])}]})
         end
     end).
-
-ensure_index_file() ->
-    Body = <<"<!DOCTYPE html>\n<html>\n<body>\nHello world\n</body>\n</html>">>,
-    file:write_file(filename:join([?TEMPDIR, "index.html"]), Body).