diff options
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/test/design_docs.js | 7 | ||||
-rw-r--r-- | share/www/script/test/view_errors.js | 26 |
2 files changed, 30 insertions, 3 deletions
diff --git a/share/www/script/test/design_docs.js b/share/www/script/test/design_docs.js index ebf0e74d..8f003efa 100644 --- a/share/www/script/test/design_docs.js +++ b/share/www/script/test/design_docs.js @@ -16,6 +16,12 @@ couchTests.design_docs = function(debug) { db.createDb(); if (debug) debugger; + run_on_modified_server( + [{section: "query_server_config", + key: "reduce_limit", + value: "false"}], +function() { + var numDocs = 500; function makebigstring(power) { @@ -104,4 +110,5 @@ couchTests.design_docs = function(debug) { restartServer(); T(db.open(designDoc._id) == null); T(db.view("test/no_docs") == null); +}); }; diff --git a/share/www/script/test/view_errors.js b/share/www/script/test/view_errors.js index 12225e67..1a613c04 100644 --- a/share/www/script/test/view_errors.js +++ b/share/www/script/test/view_errors.js @@ -75,13 +75,26 @@ couchTests.view_errors = function(debug) { _id:"_design/test", language: "javascript", views: { - no_reduce: {map:"function(doc) {emit(doc._id, null);}"}, - with_reduce: {map:"function (doc) {emit(doc.integer, doc.integer)};", - reduce:"function (keys, values) { return sum(values); };"}, + "no_reduce": {map:"function(doc) {emit(doc._id, null);}"}, + "with_reduce": { + map:"function (doc) {emit(doc.integer, doc.integer)};", + reduce:"function (keys, values) { return sum(values); };"} } }; T(db.save(designDoc).ok); + var designDoc2 = { + _id:"_design/testbig", + language: "javascript", + views: { + "reduce_too_big" : { + map:"function (doc) {emit(doc.integer, doc.integer)};", + reduce:"function (keys, values) { var chars = []; for (var i=0; i < 1000; i++) {chars.push('wazzap');};return chars; };"} + } + }; + T(db.save(designDoc2).ok); + + try { db.view("test/no_reduce", {group: true}); T(0 == 1); @@ -117,4 +130,11 @@ couchTests.view_errors = function(debug) { result = JSON.parse(xhr.responseText); T(result.error == "bad_request"); T(result.reason == "`keys` member must be a array."); + + // if the reduce grows to fast, throw an overflow error + var path = "/test_suite_db/_design/testbig/_view/reduce_too_big"; + xhr = CouchDB.request("GET", path); + T(xhr.status == 500); + result = JSON.parse(xhr.responseText); + T(result.error == "reduce_overflow_error"); }; |