Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7A58E200BC9 for ; Sat, 12 Nov 2016 01:22:42 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7784C160B14; Sat, 12 Nov 2016 00:22:42 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C67B7160AF6 for ; Sat, 12 Nov 2016 01:22:41 +0100 (CET) Received: (qmail 67709 invoked by uid 500); 12 Nov 2016 00:22:41 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 67691 invoked by uid 99); 12 Nov 2016 00:22:40 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Nov 2016 00:22:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D8945E0362; Sat, 12 Nov 2016 00:22:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: iilyak@apache.org To: commits@couchdb.apache.org Date: Sat, 12 Nov 2016 00:22:40 -0000 Message-Id: <204a3d37a0804b8e9da16261fdf5b374@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] couch commit: updated refs/heads/master to ac69856 archived-at: Sat, 12 Nov 2016 00:22:42 -0000 Repository: couchdb-couch Updated Branches: refs/heads/master 8f53c1fc9 -> ac698562b 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/master Commit: 2f26dd234e08c8381fd5177ed43c9e1cefd630b0 Parents: 8f53c1f Author: ILYA Khlopotov Authored: Thu Oct 13 14:56:19 2016 -0700 Committer: ILYA Khlopotov 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),