From 9a93b44ef02014a6e269b70d8c29362a3e4b3afb Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Sat, 20 Sep 2008 22:18:45 +0000 Subject: reduce=false closes COUCHDB-76 git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@697427 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch_tests.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'share/www/script/couch_tests.js') diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 7c48a79a..cc08e6f8 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -539,6 +539,40 @@ var tests = { }, + reduce_false: function(debug) { + var db = new CouchDB("test_suite_db"); + db.deleteDb(); + db.createDb(); + if (debug) debugger; + + var numDocs = 5; + var docs = makeDocs(1,numDocs + 1); + T(db.bulkSave(docs).ok); + var summate = function(N) {return (N+1)*N/2;}; + + var designDoc = { + _id:"_design/test", + language: "javascript", + views: { + summate: {map:"function (doc) {emit(doc.integer, doc.integer)};", + reduce:"function (keys, values) { return sum(values); };"}, + } + }; + T(db.save(designDoc).ok); + + // Test that the reduce works + var res = db.view('test/summate'); + T(res.rows.length == 1 && res.rows[0].value == summate(5)); + + //Test that we get our docs back + res = db.view('test/summate', {reduce: false}); + T(res.rows.length == 5); + for(var i=0; i<5; i++) + { + T(res.rows[i].value == i+1); + } + }, + multiple_rows: function(debug) { var db = new CouchDB("test_suite_db"); db.deleteDb(); -- cgit v1.2.3