summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2021-12-13 00:19:06 -0500
committerNick Vatamaniuc <vatamane@apache.org>2021-12-13 00:30:01 -0500
commit1bd3b653567da72886ece10812ee9f8f41dc5cb8 (patch)
tree9475db2db4d014288ad1d79d2a3be22e4b873398
parentae67383383c9d022ce618c2a3b98ace318843c1e (diff)
downloadcouchdb-check-erlfmt-format-in-build-stage.tar.gz
Reformat a few more files which slipped through the crackscheck-erlfmt-format-in-build-stage
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.
-rw-r--r--src/chttpd/src/chttpd_misc.erl12
-rw-r--r--src/chttpd/test/eunit/chttpd_dbs_info_test.erl125
-rw-r--r--src/couch/test/eunit/couchdb_vhosts_tests.erl7
-rw-r--r--src/couch_replicator/test/eunit/couch_replicator_filtered_tests.erl21
-rw-r--r--src/couch_replicator/test/eunit/couch_replicator_retain_stats_between_job_runs.erl16
5 files changed, 111 insertions, 70 deletions
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index ca1794cba..4340823b4 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 71ee86bc9..6c648b1b7 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 635b8f9a6..d1b758914 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 41f1772e6..b77b83daa 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 ba29a3c68..9ffcc9e2c 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 = [