summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Joseph Davis <davisp@apache.org>2009-11-12 02:15:25 +0000
committerPaul Joseph Davis <davisp@apache.org>2009-11-12 02:15:25 +0000
commit22d7cb27c21c579eb28ca1ba6fadfee13f1dab72 (patch)
treed9ff18e210560985a240ab2ab7c13cb0f4525a30
parent9032cfd7e12c5935982dd0c8b4e3d0be15c869fa (diff)
ErlView test case with a larger data set.
I'm unable to reproduce COUCHDB-567 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@835193 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/www/script/test/erlang_views.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/share/www/script/test/erlang_views.js b/share/www/script/test/erlang_views.js
index 2af26b5a..c3201cdd 100644
--- a/share/www/script/test/erlang_views.js
+++ b/share/www/script/test/erlang_views.js
@@ -93,5 +93,40 @@ couchTests.erlang_views = function(debug) {
var xhr = CouchDB.request("GET", url);
T(xhr.status == 200, "standard get should be 200");
T(xhr.responseText == "head2tail");
+
+ // Larger dataset
+
+ db.deleteDb();
+ db.createDb();
+ var words = "foo bar abc def baz xxyz".split(/\s+/);
+
+ var docs = [];
+ for(var i = 0; i < 250; i++) {
+ var body = [];
+ for(var j = 0; j < 100; j++) {
+ body.push({
+ word: words[j%words.length],
+ count: j
+ });
+ }
+ docs.push({
+ "_id": "test-" + i,
+ "words": body
+ });
+ }
+ T(db.bulkSave(docs).length, 250, "Saved big doc set.");
+
+ var mfun = 'fun({Doc}) -> ' +
+ 'Words = proplists:get_value(<<"words">>, Doc), ' +
+ 'lists:foreach(fun({Word}) -> ' +
+ 'WordString = proplists:get_value(<<"word">>, Word), ' +
+ 'Count = proplists:get_value(<<"count">>, Word), ' +
+ 'Emit(WordString , Count) ' +
+ 'end, Words) ' +
+ 'end.';
+
+ var rfun = 'fun(Keys, Values, RR) -> length(Values) end.';
+ var results = db.query(mfun, rfun, null, null, "erlang");
+ alert(JSON.stringify(results));
});
};