couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject couch-mrview commit: updated refs/heads/537-whitelist-builtin-reduce-funs to 6343efd
Date Wed, 01 Jul 2015 01:32:26 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/537-whitelist-builtin-reduce-funs fc90f2476 -> 6343efd67 (forced update)


Add tests for design document validations

COUCHDB-537


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/6343efd6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/6343efd6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/6343efd6

Branch: refs/heads/537-whitelist-builtin-reduce-funs
Commit: 6343efd6768a3d4d4ff2c6e1b22200f4e4aaca3f
Parents: edb2c85
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Tue Jun 30 21:27:41 2015 -0400
Committer: Adam Kocoloski <adam@cloudant.com>
Committed: Tue Jun 30 21:32:17 2015 -0400

----------------------------------------------------------------------
 test/couch_mrview_ddoc_validation_tests.erl | 78 ++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/6343efd6/test/couch_mrview_ddoc_validation_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_mrview_ddoc_validation_tests.erl b/test/couch_mrview_ddoc_validation_tests.erl
new file mode 100644
index 0000000..17cd4d3
--- /dev/null
+++ b/test/couch_mrview_ddoc_validation_tests.erl
@@ -0,0 +1,78 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_mrview_ddoc_validation_tests).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
+
+setup() ->
+    {ok, Db} = couch_mrview_test_util:init_db(?tempdb(), map),
+    Db.
+
+teardown(Db) ->
+    couch_db:close(Db),
+    couch_server:delete(Db#db.name, [?ADMIN_CTX]),
+    ok.
+
+ddoc_validation_test_() ->
+    {
+        "ddoc validation tests",
+        {
+            setup,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
+            {
+                foreach,
+                fun setup/0, fun teardown/1,
+                [
+                    fun should_reject_invalid_js_map/1,
+                    fun should_reject_invalid_js_reduce/1,
+                    fun should_reject_invalid_builtin_reduce/1
+                ]
+            }
+        }
+    }.
+
+should_reject_invalid_js_map(Db) ->
+    Doc = couch_doc:from_json_obj({[
+        {<<"_id">>, <<"_design/should_reject_invalid_js_map">>},
+        {<<"views">>, {[
+            {<<"foo">>, {[
+                {<<"map">>, <<"function(doc) }{">>}
+            ]}}
+        ]}}
+    ]}),
+    ?_assertThrow({compilation_error, _}, couch_db:update_doc(Db, Doc, [])).
+
+should_reject_invalid_js_reduce(Db) ->
+    Doc = couch_doc:from_json_obj({[
+        {<<"_id">>, <<"_design/should_reject_invalid_js_reduce">>},
+        {<<"views">>, {[
+            {<<"foo">>, {[
+                {<<"map">>, <<"function(doc) { emit(null); }">>},
+                {<<"reduce">>, <<"function(k, v, r) }{}">>}
+            ]}}
+        ]}}
+    ]}),
+    ?_assertThrow({compilation_error, _}, couch_db:update_doc(Db, Doc, [])).
+
+should_reject_invalid_builtin_reduce(Db) ->
+    Doc = couch_doc:from_json_obj({[
+        {<<"_id">>, <<"_design/should_reject_invalid_builtin_reduce">>},
+        {<<"views">>, {[
+            {<<"foo">>, {[
+                {<<"map">>, <<"function(doc) { emit(null); }">>},
+                {<<"reduce">>, <<"_foobar">>}
+            ]}}
+        ]}}
+    ]}),
+    ?_assertThrow({invalid_design_doc, _}, couch_db:update_doc(Db, Doc, [])).


Mime
View raw message