You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2021/10/24 19:30:33 UTC

[couchdb] 01/01: Eliminate eunit compiler warnings

This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a commit to branch eliminate-eunit-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 1d9c9e0b81d165e525c77dbaab97ae33b9788ab3
Author: Jay Doane <ja...@apache.org>
AuthorDate: Sun Oct 24 12:22:26 2021 -0700

    Eliminate eunit compiler warnings
    
    - Unused functions in `couch_util_tests`
    - Unused variables in `couch_prometheus_e2e_tests`
    - Unused variable in `dreyfus_blacklist_await_test`
    - Deprecated BIF `erlang:now/0` in `dreyfus_purge_test`
    - `export_all` flag in dreyfus tests
    - Unused variable in `mem3_reshard_test`
---
 src/couch/test/eunit/couch_util_tests.erl              | 18 ------------------
 .../test/eunit/couch_prometheus_e2e_tests.erl          | 11 ++---------
 src/dreyfus/test/dreyfus_blacklist_await_test.erl      |  4 ++--
 src/dreyfus/test/dreyfus_purge_test.erl                |  5 +++--
 src/dreyfus/test/dreyfus_test_util.erl                 |  4 +++-
 src/mem3/test/eunit/mem3_reshard_test.erl              |  1 -
 6 files changed, 10 insertions(+), 33 deletions(-)

diff --git a/src/couch/test/eunit/couch_util_tests.erl b/src/couch/test/eunit/couch_util_tests.erl
index f6d7d95..44a5cce 100644
--- a/src/couch/test/eunit/couch_util_tests.erl
+++ b/src/couch/test/eunit/couch_util_tests.erl
@@ -15,24 +15,6 @@
 -include_lib("couch/include/couch_eunit.hrl").
 
 
-setup() ->
-    %% We cannot start driver from here since it becomes bounded to eunit
-    %% master process and the next couch_server_sup:start_link call will
-    %% fail because server couldn't load driver since it already is.
-    %%
-    %% On other hand, we cannot unload driver here due to
-    %% {error, not_loaded_by_this_process} while it is. Any ideas is welcome.
-    %%
-    Ctx = test_util:start_couch(),
-    %% config:start_link(?CONFIG_CHAIN),
-    Ctx.
-
-teardown(Ctx) ->
-    ok = test_util:stop_couch(Ctx),
-    %% config:stop(),
-    ok.
-
-
 validate_callback_exists_test_() ->
     {
         "validate_callback_exists tests",
diff --git a/src/couch_prometheus/test/eunit/couch_prometheus_e2e_tests.erl b/src/couch_prometheus/test/eunit/couch_prometheus_e2e_tests.erl
index c862b9a..bc782bc 100644
--- a/src/couch_prometheus/test/eunit/couch_prometheus_e2e_tests.erl
+++ b/src/couch_prometheus/test/eunit/couch_prometheus_e2e_tests.erl
@@ -83,19 +83,14 @@ node_see_updated_metrics(Url) ->
 node_call_prometheus_http(_) ->
     maybe_start_http_server("true"),
     Url = construct_url(?PROM_PORT),
-    {ok, RC1, _, _} = test_request:get(
-            Url,
-            [?CONTENT_JSON, ?AUTH],
-            []
-        ),
     % since this port doesn't require auth, this should work
-    {ok, RC2, _, _} = test_request:get(
+    {ok, RC, _, _} = test_request:get(
             Url,
             [?CONTENT_JSON],
             []
         ),
     delete_db(Url),
-    ?_assertEqual(200, RC2).
+    ?_assertEqual(200, RC).
 
 % we don't start the http server
 deny_prometheus_http(_) ->
@@ -121,8 +116,6 @@ construct_url(Port) ->
     lists:concat(["http://", Addr, ":", Port, "/_node/_local/_prometheus"]).
 
 create_db(Url) ->
-    Addr = config:get("chttpd", "bind_address", "127.0.0.1"),
-    Port = mochiweb_socket_server:get(chttpd, port),
     {ok, Status, _, _} = test_request:put(Url, [?CONTENT_JSON, ?AUTH], "{}"),
     ?assert(Status =:= 201 orelse Status =:= 202).
 
diff --git a/src/dreyfus/test/dreyfus_blacklist_await_test.erl b/src/dreyfus/test/dreyfus_blacklist_await_test.erl
index 28a5e7f..82665eb 100644
--- a/src/dreyfus/test/dreyfus_blacklist_await_test.erl
+++ b/src/dreyfus/test/dreyfus_blacklist_await_test.erl
@@ -62,8 +62,8 @@ do_not_await_1() ->
     State = create_state(?DBNAME, Index, nil, nil, []),
     Msg = "Index Blocked from Updating - db: ~p, ddocid: ~p name: ~p",
     Return = wait_log_message(Msg, fun() ->
-        {noreply, NewState} = dreyfus_index:handle_call({await, 1},
-        self(), State)
+        {noreply, _NewState} = dreyfus_index:handle_call({await, 1},
+            self(), State)
     end),
     ?assertEqual(Return, ok).
 
diff --git a/src/dreyfus/test/dreyfus_purge_test.erl b/src/dreyfus/test/dreyfus_purge_test.erl
index 5fa4bc9..954503d 100644
--- a/src/dreyfus/test/dreyfus_purge_test.erl
+++ b/src/dreyfus/test/dreyfus_purge_test.erl
@@ -27,6 +27,8 @@
         test_local_doc/0, test_delete_local_doc/0, test_purge_search/0]).
 
 -compile(export_all).
+-compile(nowarn_export_all).
+
 
 test_all() ->
     test_purge_single(),
@@ -703,9 +705,8 @@ test_purge_search() ->
 
 %private API
 db_name() ->
-    Nums = tuple_to_list(erlang:now()),
     Prefix = "test-db",
-    Suffix = lists:concat([integer_to_list(Num) || Num <- Nums]),
+    Suffix = integer_to_list(erlang:system_time()),
     list_to_binary(Prefix ++ "-" ++ Suffix).
 
 purge_docs(DBName, DocIds) ->
diff --git a/src/dreyfus/test/dreyfus_test_util.erl b/src/dreyfus/test/dreyfus_test_util.erl
index 631bc10..79fd9b5 100644
--- a/src/dreyfus/test/dreyfus_test_util.erl
+++ b/src/dreyfus/test/dreyfus_test_util.erl
@@ -1,6 +1,8 @@
 -module(dreyfus_test_util).
 
--compile(export_all).
+-export([
+    wait_config_change/2
+]).
 
 -include_lib("couch/include/couch_db.hrl").
 
diff --git a/src/mem3/test/eunit/mem3_reshard_test.erl b/src/mem3/test/eunit/mem3_reshard_test.erl
index 1122590..65f2b4b 100644
--- a/src/mem3/test/eunit/mem3_reshard_test.erl
+++ b/src/mem3/test/eunit/mem3_reshard_test.erl
@@ -519,7 +519,6 @@ target_reset_in_initial_copy(#{db1 := Db}) ->
 
 split_an_incomplete_shard_map(#{db1 := Db}) ->
     {timeout, ?TIMEOUT, ?_test(begin
-        [#shard{} = Src] = lists:sort(mem3:local_shards(Db)),
         [#shard{name=Shard}] = lists:sort(mem3:local_shards(Db)),
         meck:expect(mem3_util, calculate_max_n, 1, 0),
         ?assertMatch({error, {not_enough_shard_copies, _}},