couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [07/13] couch-mrview commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to e7932f7
Date Tue, 04 Apr 2017 21:15:41 GMT
Add send_list_row test suite


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/c01d4c08
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/c01d4c08
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/c01d4c08

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: c01d4c088e1073c669e900cc14d0404a00ea36ff
Parents: 56616fa
Author: Jay Doane <jay.s.doane@gmail.com>
Authored: Wed Mar 15 23:01:28 2017 -0700
Committer: Jay Doane <jay.s.doane@gmail.com>
Committed: Wed Mar 15 23:01:28 2017 -0700

----------------------------------------------------------------------
 src/couch_mrview_show.erl | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/c01d4c08/src/couch_mrview_show.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_show.erl b/src/couch_mrview_show.erl
index f79ad62..4f59acc 100644
--- a/src/couch_mrview_show.erl
+++ b/src/couch_mrview_show.erl
@@ -424,4 +424,42 @@ should_apply_headers_with_merge_overwrite() ->
         ?assertEqual({NewHeaders}, JsonHeaders)
     end).
 
+
+send_list_row_test_() ->
+    Cases = couch_tests_combinatorics:product([
+        [
+            {"[<<\"end\">>, [], []]", fun(_, _) -> [<<"end">>,
[], []] end},
+            {"[<<\"end\">>, []]", fun(_, _) -> [<<"end">>, []]
end},
+            {"throw(timeout)", fun(_, _) -> throw(timeout) end}
+        ],
+        [
+            req,
+            undefined
+        ]]),
+    {"Ensure send_list_row returns a valid response on end or error",
+        {setup, fun setup/0, fun(_) -> meck:unload() end, [
+            {
+                lists:flatten(io_lib:format("~s -- ~p", [N, R])),
+                should_return_valid_response(F, R)
+            } || [{N, F}, R] <- Cases
+        ]}
+    }.
+
+setup() ->
+    ok = meck:expect(chttpd, send_chunk,
+        fun(Resp, _) -> {ok, Resp} end),
+    ok = meck:expect(chttpd, send_chunked_error,
+        fun(Resp, _) -> {ok, Resp} end),
+    ok = meck:expect(chttpd, start_chunked_response,
+        fun(_, _, _) -> {ok, resp} end),
+    ok = meck:expect(chttpd_external, parse_external_response, 1,
+        #extern_resp_args{headers = []}).
+
+should_return_valid_response(Spec, Req) ->
+    ?_test(begin
+        ok = meck:expect(couch_query_servers, proc_prompt, Spec),
+        Acc = #lacc{qserver = {proc, undefined}, req = Req, resp = resp},
+        ?assertEqual({stop, resp}, send_list_row([], Acc))
+    end).
+
 -endif.


Mime
View raw message