diff options
author | Garren Smith <garren.smith@gmail.com> | 2018-10-04 10:45:03 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2018-10-04 10:47:58 +0200 |
commit | 8472649607d8b716a416c18fc2c091c5d31f4c2b (patch) | |
tree | deaa1be1e57cd82a7195060fb784f337715275a7 | |
parent | 3cd640c839eacffb4ad2874dde10031269e46050 (diff) | |
download | couchdb-fix-eunit-partitions.tar.gz |
fix eunit tests for partitions PRfix-eunit-partitions
-rw-r--r-- | src/chttpd/src/chttpd_view.erl | 4 | ||||
-rw-r--r-- | src/chttpd/test/chttpd_db_bulk_get_test.erl | 33 |
2 files changed, 28 insertions, 9 deletions
diff --git a/src/chttpd/src/chttpd_view.erl b/src/chttpd/src/chttpd_view.erl index e56be0c7b..7c1dc81bb 100644 --- a/src/chttpd/src/chttpd_view.erl +++ b/src/chttpd/src/chttpd_view.erl @@ -20,9 +20,11 @@ multi_query_view(Req, Db, DDoc, ViewName, Queries) -> Args0 = couch_mrview_http:parse_params(Req, undefined), {ok, #mrst{views=Views}} = couch_mrview_util:ddoc_to_mrst(Db, DDoc), Args1 = couch_mrview_util:set_view_type(Args0, ViewName, Views), + % We don't support multi query in partitions + Args2 = couch_mrview_util:set_extra(Args1, partitioned, false), ArgQueries = lists:map(fun({Query}) -> QueryArg = couch_mrview_http:parse_params(Query, undefined, - Args1, [decoded]), + Args2, [decoded]), QueryArg1 = couch_mrview_util:set_view_type(QueryArg, ViewName, Views), couch_mrview_util:validate_args(QueryArg1) end, Queries), diff --git a/src/chttpd/test/chttpd_db_bulk_get_test.erl b/src/chttpd/test/chttpd_db_bulk_get_test.erl index f8921311b..3573619a8 100644 --- a/src/chttpd/test/chttpd_db_bulk_get_test.erl +++ b/src/chttpd/test/chttpd_db_bulk_get_test.erl @@ -14,6 +14,7 @@ -include_lib("couch/include/couch_eunit.hrl"). -include_lib("couch/include/couch_db.hrl"). +-include("couch/src/couch_db_int.hrl"). -define(TIMEOUT, 3000). @@ -26,6 +27,7 @@ setup() -> mock(couch_stats), mock(fabric), mock(mochireq), + mock(mem3), Pid = spawn_accumulator(), Pid. @@ -38,7 +40,8 @@ teardown(Pid) -> meck:unload(couch_httpd), meck:unload(couch_stats), meck:unload(fabric), - meck:unload(mochireq). + meck:unload(mochireq), + meck:unload(mem3). bulk_get_test_() -> @@ -95,7 +98,8 @@ should_get_doc_with_all_revs(Pid) -> DocRevB = #doc{id = DocId, body = {[{<<"_rev">>, <<"1-CDE">>}]}}, mock_open_revs(all, {ok, [{ok, DocRevA}, {ok, DocRevB}]}), - chttpd_db:db_req(Req, nil), + Db = fake_db(), + chttpd_db:db_req(Req, Db), [{Result}] = get_results_from_response(Pid), ?assertEqual(DocId, couch_util:get_value(<<"id">>, Result)), @@ -115,7 +119,8 @@ should_validate_doc_with_bad_id(Pid) -> DocId = <<"_docudoc">>, Req = fake_request(DocId), - chttpd_db:db_req(Req, nil), + Db = fake_db(), + chttpd_db:db_req(Req, Db), [{Result}] = get_results_from_response(Pid), ?assertEqual(DocId, couch_util:get_value(<<"id">>, Result)), @@ -138,7 +143,8 @@ should_validate_doc_with_bad_rev(Pid) -> Rev = <<"revorev">>, Req = fake_request(DocId, Rev), - chttpd_db:db_req(Req, nil), + Db = fake_db(), + chttpd_db:db_req(Req, Db), [{Result}] = get_results_from_response(Pid), ?assertEqual(DocId, couch_util:get_value(<<"id">>, Result)), @@ -162,7 +168,8 @@ should_validate_missing_doc(Pid) -> Req = fake_request(DocId, Rev), mock_open_revs([{1,<<"revorev">>}], {ok, []}), - chttpd_db:db_req(Req, nil), + Db = fake_db(), + chttpd_db:db_req(Req, Db), [{Result}] = get_results_from_response(Pid), ?assertEqual(DocId, couch_util:get_value(<<"id">>, Result)), @@ -186,7 +193,8 @@ should_validate_bad_atts_since(Pid) -> Req = fake_request(DocId, Rev, <<"badattsince">>), mock_open_revs([{1,<<"revorev">>}], {ok, []}), - chttpd_db:db_req(Req, nil), + Db = fake_db(), + chttpd_db:db_req(Req, Db), [{Result}] = get_results_from_response(Pid), ?assertEqual(DocId, couch_util:get_value(<<"id">>, Result)), @@ -210,10 +218,11 @@ should_include_attachments_when_atts_since_specified(_) -> Req = fake_request(DocId, Rev, [<<"1-abc">>]), mock_open_revs([{1,<<"revorev">>}], {ok, []}), - chttpd_db:db_req(Req, nil), + Db = fake_db(), + chttpd_db:db_req(Req, Db), ?_assert(meck:called(fabric, open_revs, - [nil, DocId, [{1, <<"revorev">>}], + [Db, DocId, [{1, <<"revorev">>}], [{atts_since, [{1, <<"abc">>}]}, attachments]])). %% helpers @@ -233,6 +242,10 @@ fake_request(DocId, Rev, AttsSince) -> {<<"atts_since">>, AttsSince}]}]}]}). +fake_db() -> + #db{name = <<"dbName">>}. + + mock_open_revs(RevsReq0, RevsResp) -> ok = meck:expect(fabric, open_revs, fun(_, _, RevsReq1, _) -> @@ -276,6 +289,10 @@ mock(fabric) -> mock(config) -> ok = meck:new(config, [passthrough]), ok = meck:expect(config, get, fun(_, _, Default) -> Default end), + ok; +mock(mem3) -> + ok = meck:new(mem3, [passthrough]), + ok = meck:expect(mem3, is_partitioned, 1, false), ok. |