You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2021/12/13 15:23:11 UTC

[couchdb] 02/02: Reformat a few more files which slipped through the cracks

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

vatamane pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 8d329e587dacc0b94cdbc2a562270042214dcca2
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Dec 13 00:19:06 2021 -0500

    Reformat a few more files which slipped through the cracks
    
    One set of files is from a recent PR which we failed to detect because
    of the Eralng 20 issue. The others are some test modules which had
    been skipped during the initial reformatting.
---
 src/chttpd/src/chttpd_misc.erl                     |  12 +-
 src/chttpd/test/eunit/chttpd_dbs_info_test.erl     | 125 +++++++++++++--------
 src/couch/test/eunit/couchdb_vhosts_tests.erl      |   7 +-
 .../test/eunit/couch_replicator_filtered_tests.erl |  21 ++--
 ...ch_replicator_retain_stats_between_job_runs.erl |  16 +--
 5 files changed, 111 insertions(+), 70 deletions(-)

diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index ca1794c..4340823 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -140,8 +140,9 @@ handle_all_dbs_info_req(Req) ->
 all_dbs_info_callback({meta, _Meta}, #vacc{resp = Resp0} = Acc) ->
     {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, "["),
     {ok, Acc#vacc{resp = Resp1}};
-all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} = Acc)
-  when Acc#vacc.req#httpd.path_parts =:= [<<"_all_dbs">>] ->
+all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} = Acc) when
+    Acc#vacc.req#httpd.path_parts =:= [<<"_all_dbs">>]
+->
     Prepend = couch_mrview_http:prepend_val(Acc),
     case couch_util:get_value(id, Row) of
         <<"_design", _/binary>> ->
@@ -150,8 +151,9 @@ all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} = Acc)
             {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, [Prepend, ?JSON_ENCODE(DbName)]),
             {ok, Acc#vacc{prepend = ",", resp = Resp1}}
     end;
-all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} = Acc)
-  when Acc#vacc.req#httpd.path_parts =:= [<<"_dbs_info">>] ->
+all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} = Acc) when
+    Acc#vacc.req#httpd.path_parts =:= [<<"_dbs_info">>]
+->
     Prepend = couch_mrview_http:prepend_val(Acc),
     DbName = couch_util:get_value(id, Row),
     case chttpd_util:get_db_info(DbName) of
@@ -173,7 +175,7 @@ all_dbs_info_callback({error, Reason}, #vacc{resp = Resp0} = Acc) ->
     {ok, Resp1} = chttpd:send_delayed_error(Resp0, Reason),
     {ok, Acc#vacc{resp = Resp1}}.
 
-handle_dbs_info_req(#httpd{method='GET'}=Req) ->
+handle_dbs_info_req(#httpd{method = 'GET'} = Req) ->
     handle_all_dbs_info_req(Req);
 handle_dbs_info_req(#httpd{method = 'POST'} = Req) ->
     chttpd:validate_ctype(Req, "application/json"),
diff --git a/src/chttpd/test/eunit/chttpd_dbs_info_test.erl b/src/chttpd/test/eunit/chttpd_dbs_info_test.erl
index 71ee86b..6c648b1 100644
--- a/src/chttpd/test/eunit/chttpd_dbs_info_test.erl
+++ b/src/chttpd/test/eunit/chttpd_dbs_info_test.erl
@@ -56,8 +56,11 @@ mock_timeout() ->
     meck:expect(fabric_util, request_timeout, fun() -> 0 end).
 
 mock_db_not_exist() ->
-    meck:expect(chttpd_util, get_db_info,
-        fun(_) -> {error, database_does_not_exist} end).
+    meck:expect(
+        chttpd_util,
+        get_db_info,
+        fun(_) -> {error, database_does_not_exist} end
+    ).
 
 dbs_info_test_() ->
     {
@@ -93,132 +96,162 @@ dbs_info_test_() ->
         }
     }.
 
-
 get_db_info_should_return_db_info(_) ->
     DbInfo = fabric:get_db_info("db1"),
     ?_assertEqual(DbInfo, chttpd_util:get_db_info("db1")).
 
-
 get_db_info_should_return_error_when_db_not_exist(_) ->
-    ?_assertEqual({error, database_does_not_exist},
-        chttpd_util:get_db_info("db_not_exist")).
-
+    ?_assertEqual(
+        {error, database_does_not_exist},
+        chttpd_util:get_db_info("db_not_exist")
+    ).
 
 get_db_info_should_return_error_when_time_out(_) ->
     ?_test(
         begin
             mock_timeout(),
             ?assertEqual({error, timeout}, chttpd_util:get_db_info("db1"))
-        end).
-
+        end
+    ).
 
 should_return_error_for_put_dbs_info(Url) ->
     ?_test(
         begin
-            {ok, Code, _, ResultBody} = test_request:put(Url
-            ++ "_dbs_info", [?CONTENT_JSON, ?AUTH], ""),
+            {ok, Code, _, ResultBody} = test_request:put(
+                Url ++
+                    "_dbs_info",
+                [?CONTENT_JSON, ?AUTH],
+                ""
+            ),
             {Body} = jiffy:decode(ResultBody),
             ?assertEqual(405, Code),
-            ?assertEqual(<<"method_not_allowed">>,
-                couch_util:get_value(<<"error">>, Body))
-        end).
-
+            ?assertEqual(
+                <<"method_not_allowed">>,
+                couch_util:get_value(<<"error">>, Body)
+            )
+        end
+    ).
 
 should_return_dbs_info_for_get_dbs_info(Url) ->
     ?_test(
         begin
-            {ok, _, _, ResultBody} = test_request:get(Url
-            ++ "_dbs_info", [?CONTENT_JSON, ?AUTH]),
+            {ok, _, _, ResultBody} = test_request:get(
+                Url ++
+                    "_dbs_info",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             BodyJson = jiffy:decode(ResultBody),
             {Db1Data} = lists:nth(1, BodyJson),
             {Db2Data} = lists:nth(2, BodyJson),
             ?assertEqual(2, length(BodyJson)),
             ?assertEqual(<<"db1">>, couch_util:get_value(<<"key">>, Db1Data)),
             ?assertEqual(<<"db2">>, couch_util:get_value(<<"key">>, Db2Data))
-        end).
-
+        end
+    ).
 
 should_return_nothing_when_db_not_exist_for_get_dbs_info(Url) ->
     ?_test(
         begin
             mock_db_not_exist(),
-            {ok, Code, _, ResultBody} = test_request:get(Url
-            ++ "_dbs_info", [?CONTENT_JSON, ?AUTH]),
+            {ok, Code, _, ResultBody} = test_request:get(
+                Url ++
+                    "_dbs_info",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             BodyJson = jiffy:decode(ResultBody),
             ?assertEqual(200, Code),
             ?assertEqual([], BodyJson)
-        end).
-
+        end
+    ).
 
 should_return_500_time_out_when_time_is_not_enough_for_get_dbs_info(Url) ->
     ?_test(
         begin
             mock_timeout(),
-            {ok, Code, _, ResultBody} = test_request:get(Url ++ "_dbs_info"
-                ++ "?buffer_response=true", [?CONTENT_JSON, ?AUTH]),
+            {ok, Code, _, ResultBody} = test_request:get(
+                Url ++ "_dbs_info" ++
+                    "?buffer_response=true",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             {Body} = jiffy:decode(ResultBody),
             ?assertEqual(500, Code),
             ?assertEqual(<<"timeout">>, couch_util:get_value(<<"error">>, Body))
-        end).
-
+        end
+    ).
 
 should_return_db2_for_get_dbs_info_with_descending(Url) ->
     ?_test(
         begin
-            {ok, _, _, ResultBody} = test_request:get(Url ++ "_dbs_info"
-                ++ "?descending=true", [?CONTENT_JSON, ?AUTH]),
+            {ok, _, _, ResultBody} = test_request:get(
+                Url ++ "_dbs_info" ++
+                    "?descending=true",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             BodyJson = jiffy:decode(ResultBody),
             {Db1Data} = lists:nth(1, BodyJson),
             {Db2Data} = lists:nth(2, BodyJson),
             ?assertEqual(2, length(BodyJson)),
             ?assertEqual(<<"db2">>, couch_util:get_value(<<"key">>, Db1Data)),
             ?assertEqual(<<"db1">>, couch_util:get_value(<<"key">>, Db2Data))
-        end).
-
+        end
+    ).
 
 should_return_db1_for_get_dbs_info_with_limit_1(Url) ->
     ?_test(
         begin
-            {ok, _, _, ResultBody} = test_request:get(Url ++ "_dbs_info"
-                ++ "?limit=1", [?CONTENT_JSON, ?AUTH]),
+            {ok, _, _, ResultBody} = test_request:get(
+                Url ++ "_dbs_info" ++
+                    "?limit=1",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             BodyJson = jiffy:decode(ResultBody),
             {DbData} = lists:nth(1, BodyJson),
             ?assertEqual(1, length(BodyJson)),
             ?assertEqual(<<"db1">>, couch_util:get_value(<<"key">>, DbData))
-        end).
-
+        end
+    ).
 
 should_return_db2_for_get_dbs_info_with_skip_1(Url) ->
     ?_test(
         begin
-            {ok, _, _, ResultBody} = test_request:get(Url ++ "_dbs_info"
-                ++ "?skip=1", [?CONTENT_JSON, ?AUTH]),
+            {ok, _, _, ResultBody} = test_request:get(
+                Url ++ "_dbs_info" ++
+                    "?skip=1",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             BodyJson = jiffy:decode(ResultBody),
             {DbData} = lists:nth(1, BodyJson),
             ?assertEqual(1, length(BodyJson)),
             ?assertEqual(<<"db2">>, couch_util:get_value(<<"key">>, DbData))
-        end).
-
+        end
+    ).
 
 should_return_dbs_info_with_correct_start_end_key(Url) ->
     ?_test(
         begin
-            {ok, _, _, ResultBody} = test_request:get(Url ++ "_dbs_info"
-                ++ "?startkey=\"db1\"&endkey=\"db2\"", [?CONTENT_JSON, ?AUTH]),
+            {ok, _, _, ResultBody} = test_request:get(
+                Url ++ "_dbs_info" ++
+                    "?startkey=\"db1\"&endkey=\"db2\"",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             BodyJson = jiffy:decode(ResultBody),
             {DbData} = lists:nth(1, BodyJson),
             ?assertEqual(2, length(BodyJson)),
             ?assertEqual(<<"db1">>, couch_util:get_value(<<"key">>, DbData))
-        end).
-
+        end
+    ).
 
 should_return_empty_list_with_wrong_start_end_key(Url) ->
     ?_test(
         begin
-            {ok, _, _, ResultBody} = test_request:get(Url ++ "_dbs_info"
-                ++ "?startkey=\"db3\"&endkey=\"db4\"", [?CONTENT_JSON, ?AUTH]),
+            {ok, _, _, ResultBody} = test_request:get(
+                Url ++ "_dbs_info" ++
+                    "?startkey=\"db3\"&endkey=\"db4\"",
+                [?CONTENT_JSON, ?AUTH]
+            ),
             ?assertEqual([], jiffy:decode(ResultBody))
-        end).
+        end
+    ).
 
 should_return_dbs_info_for_single_db(Url) ->
     ?_test(begin
diff --git a/src/couch/test/eunit/couchdb_vhosts_tests.erl b/src/couch/test/eunit/couchdb_vhosts_tests.erl
index 635b8f9..d1b7589 100644
--- a/src/couch/test/eunit/couchdb_vhosts_tests.erl
+++ b/src/couch/test/eunit/couchdb_vhosts_tests.erl
@@ -33,11 +33,12 @@ setup() ->
             {<<"_id">>, <<"_design/doc1">>},
             {<<"shows">>,
                 {[
-                    {<<"test">>,
-                        <<"function(doc, req) {\n"
+                    {<<"test">>, <<
+                        "function(doc, req) {\n"
                         "            return { json: {\n"
                         "                    requested_path: '/' + req.requested_path.join('/'),\n"
-                        "                    path: '/' + req.path.join('/')}};}">>}
+                        "                    path: '/' + req.path.join('/')}};}"
+                    >>}
                 ]}},
             {<<"rewrites">>, [
                 {[
diff --git a/src/couch_replicator/test/eunit/couch_replicator_filtered_tests.erl b/src/couch_replicator/test/eunit/couch_replicator_filtered_tests.erl
index 41f1772..b77b83d 100644
--- a/src/couch_replicator/test/eunit/couch_replicator_filtered_tests.erl
+++ b/src/couch_replicator/test/eunit/couch_replicator_filtered_tests.erl
@@ -21,12 +21,13 @@
         {<<"_id">>, <<"_design/filter_ddoc">>},
         {<<"filters">>,
             {[
-                {<<"testfilter">>,
-                    <<"\n"
+                {<<"testfilter">>, <<
+                    "\n"
                     "            function(doc, req){if (doc.class == 'mammal') return true;}\n"
-                    "        ">>},
-                {<<"queryfilter">>,
-                    <<"\n"
+                    "        "
+                >>},
+                {<<"queryfilter">>, <<
+                    "\n"
                     "            function(doc, req) {\n"
                     "                if (doc.class && req.query.starts) {\n"
                     "                    return doc.class.indexOf(req.query.starts) === 0;\n"
@@ -35,20 +36,22 @@
                     "                    return false;\n"
                     "                }\n"
                     "            }\n"
-                    "        ">>}
+                    "        "
+                >>}
             ]}},
         {<<"views">>,
             {[
                 {<<"mammals">>,
                     {[
-                        {<<"map">>,
-                            <<"\n"
+                        {<<"map">>, <<
+                            "\n"
                             "                function(doc) {\n"
                             "                    if (doc.class == 'mammal') {\n"
                             "                        emit(doc._id, null);\n"
                             "                    }\n"
                             "                }\n"
-                            "            ">>}
+                            "            "
+                        >>}
                     ]}}
             ]}}
     ]}
diff --git a/src/couch_replicator/test/eunit/couch_replicator_retain_stats_between_job_runs.erl b/src/couch_replicator/test/eunit/couch_replicator_retain_stats_between_job_runs.erl
index ba29a3c..9ffcc9e 100644
--- a/src/couch_replicator/test/eunit/couch_replicator_retain_stats_between_job_runs.erl
+++ b/src/couch_replicator/test/eunit/couch_replicator_retain_stats_between_job_runs.erl
@@ -262,13 +262,15 @@ scheduler_jobs() ->
     maps:get(<<"jobs">>, Json).
 
 vdu() ->
-    <<"function(newDoc, oldDoc, userCtx) {\n"
-    "        if(newDoc.nope === true) {\n"
-    "            throw({forbidden: 'nope'});\n"
-    "        } else {\n"
-    "            return;\n"
-    "        }\n"
-    "    }">>.
+    <<
+        "function(newDoc, oldDoc, userCtx) {\n"
+        "        if(newDoc.nope === true) {\n"
+        "            throw({forbidden: 'nope'});\n"
+        "        } else {\n"
+        "            return;\n"
+        "        }\n"
+        "    }"
+    >>.
 
 add_vdu(DbName) ->
     DocProps = [