couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject [18/50] couch commit: updated refs/heads/2971-count-distinct to ee32cd5
Date Wed, 01 Mar 2017 16:39:05 GMT
Add test suite for handling errors from fabric

COUCHDB-3195


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

Branch: refs/heads/2971-count-distinct
Commit: 2f26dd234e08c8381fd5177ed43c9e1cefd630b0
Parents: 8f53c1f
Author: ILYA Khlopotov <iilyak@apache.org>
Authored: Thu Oct 13 14:56:19 2016 -0700
Committer: ILYA Khlopotov <iilyak@apache.org>
Committed: Fri Nov 11 16:19:19 2016 -0800

----------------------------------------------------------------------
 test/couchdb_mrview_tests.erl | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/2f26dd23/test/couchdb_mrview_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_mrview_tests.erl b/test/couchdb_mrview_tests.erl
index fa9ba70..9a4cc03 100644
--- a/test/couchdb_mrview_tests.erl
+++ b/test/couchdb_mrview_tests.erl
@@ -27,6 +27,11 @@
             "var data = JSON.parse(req.body); "
             "return ['test', data];"
         "}">>}
+    ]}},
+    {<<"views">>, {[
+        {<<"view1">>, {[
+            {<<"map">>, <<"function(doc){emit(doc._id, doc._rev)}">>}
+        ]}}
     ]}}
 ]}).
 
@@ -60,7 +65,7 @@ teardown(PortType, {_Host, DbName}) ->
     delete_db(PortType, ?l2b(DbName)),
     ok.
 
-mrview_update_test_() ->
+mrview_show_test_() ->
     {
         "Check show functionality",
         {
@@ -73,6 +78,19 @@ mrview_update_test_() ->
         }
     }.
 
+mrview_query_test_() ->
+    {
+        "Check view query functionality",
+        {
+            setup,
+            fun start/0, fun teardown/1,
+            [
+                make_test_case(clustered, [fun should_return_400_for_wrong_order_of_keys/2]),
+                make_test_case(backdoor, [fun should_return_400_for_wrong_order_of_keys/2])
+            ]
+        }
+    }.
+
 make_test_case(Mod, Funs) ->
     {
         lists:flatten(io_lib:format("~s", [Mod])),
@@ -94,6 +112,22 @@ should_return_invalid_request_body(PortType, {Host, DbName}) ->
          ok
     end).
 
+should_return_400_for_wrong_order_of_keys(_PortType, {Host, DbName}) ->
+    Args = [{start_key, "\"bbb\""}, {end_key, "\"aaa\""}],
+    ?_test(begin
+         ReqUrl = Host ++ "/" ++ DbName
+              ++ "/_design/foo/_view/view1?" ++ mochiweb_util:urlencode(Args),
+         {ok, Status, _Headers, Body} = test_request:get(ReqUrl, [?AUTH]),
+         {Props} = jiffy:decode(Body),
+         ?assertEqual(
+            <<"query_parse_error">>, couch_util:get_value(<<"error">>,
Props)),
+         ?assertEqual(
+            <<"No rows can match your key range, reverse your start_key and end_key
or set descending=true">>,
+            couch_util:get_value(<<"reason">>, Props)),
+         ?assertEqual(400, Status),
+         ok
+    end).
+
 create_doc(backdoor, DbName, Id, Body) ->
     JsonDoc = couch_util:json_apply_field({<<"_id">>, Id}, Body),
     Doc = couch_doc:from_json_obj(JsonDoc),


Mime
View raw message