summaryrefslogtreecommitdiff
path: root/share/www/script/couch_tests.js
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-02-13 20:52:28 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-02-13 20:52:28 +0000
commit4b691efb97cbbe3b0150c59c25d97882260a4984 (patch)
tree601287d898553f9623591ffc70781acbe566e606 /share/www/script/couch_tests.js
parenteb81ff32d07cb8cbe1a13a495a2aabd968313821 (diff)
apply COUCHDB-252.
Allow _list functions to signal that iteration of the view should cease. Thanks davisp. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@744240 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/couch_tests.js')
-rw-r--r--share/www/script/couch_tests.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index bc4e067a..0ffee4cd 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -2796,9 +2796,33 @@ db.createDb();
}
})
}),
- qsParams: stringFun(function(head, row, req, row_number) {
+ qsParams: stringFun(function(head, row, req, row_info) {
if(head) return {body: req.query.foo};
else return {body: "\n"};
+ }),
+ stopIter: stringFun(function(head, row, req, row_info) {
+ if(head) {
+ return {body: "head"};
+ } else if(row) {
+ if(row_info.row_number > 2) return {stop: true};
+ return {body: " " + row_info.row_number};
+ } else {
+ return {body: " tail"};
+ }
+ }),
+ stopIter2: stringFun(function(head, row, req, row_info) {
+ return respondWith(req, {
+ html: function() {
+ if(head) {
+ return "head";
+ } else if(row) {
+ if(row_info.row_number > 2) return {stop: true};
+ return " " + row_info.row_number;
+ } else {
+ return " tail";
+ }
+ }
+ });
})
}
};
@@ -2870,6 +2894,15 @@ db.createDb();
// now with extra qs params
xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/qsParams/basicView?foo=blam");
T(xhr.responseText.match(/blam/));
+
+
+ // aborting iteration
+ xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/stopIter/basicView");
+ T(xhr.responseText.match(/^head 0 1 2 tail$/));
+ xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/stopIter2/basicView");
+ T(xhr.responseText.match(/^head 0 1 2 tail$/));
+
+
},
compact: function(debug) {