From 7665e449cdfff1e660ed2bbac3de4507cb063a18 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Mon, 27 Sep 2010 20:06:22 +0000 Subject: CommonJS support in map functions git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1001895 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/design_docs.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'share/www') diff --git a/share/www/script/test/design_docs.js b/share/www/script/test/design_docs.js index 8864225c..62606341 100644 --- a/share/www/script/test/design_docs.js +++ b/share/www/script/test/design_docs.js @@ -54,7 +54,18 @@ function() { summate2: {map:"function (doc) {emit(doc.integer, doc.integer)};", reduce:"function (keys, values) { return sum(values); };"}, huge_src_and_results: {map: "function(doc) { if (doc._id == \"1\") { emit(\"" + makebigstring(16) + "\", null) }}", - reduce:"function (keys, values) { return \"" + makebigstring(16) + "\"; };"} + reduce:"function (keys, values) { return \"" + makebigstring(16) + "\"; };"}, + lib : { + baz : "exports.baz = 'bam';", + foo : { + foo : "exports.foo = 'bar';", + boom : "exports.boom = 'ok';", + zoom : "exports.zoom = 'yeah';" + } + }, + commonjs : { + map : "function(doc) { emit(null, require('views/lib/foo/boom').boom)}" + } }, shows: { simple: "function() {return 'ok'};", @@ -99,10 +110,14 @@ function() { var vinfo = dinfo.view_index; TEquals(51, vinfo.disk_size); TEquals(false, vinfo.compact_running); - TEquals("3f88e53b303e2342e49a66c538c30679", vinfo.signature); + TEquals("dc3264b45b74cc6d94666e3043e07154", vinfo.signature, 'ddoc sig'); db.bulkSave(makeDocs(1, numDocs + 1)); + // test commonjs in map functions + resp = db.view("test/commonjs", {limit:1}); + T(resp.rows[0].value == 'ok'); + // test that the _all_docs view returns correctly with keys var results = db.allDocs({startkey:"_design", endkey:"_design0"}); T(results.rows.length == 1); -- cgit v1.2.3