You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by cm...@apache.org on 2008/06/04 17:44:17 UTC
svn commit: r663239 - in /incubator/couchdb/trunk/share/www/script: couch.js
couch_tests.js
Author: cmlenz
Date: Wed Jun 4 08:44:17 2008
New Revision: 663239
URL: http://svn.apache.org/viewvc?rev=663239&view=rev
Log:
Add tests for bulk_docs, to verify that COUCHDB-16 has been fixed.
Modified:
incubator/couchdb/trunk/share/www/script/couch.js
incubator/couchdb/trunk/share/www/script/couch_tests.js
Modified: incubator/couchdb/trunk/share/www/script/couch.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch.js?rev=663239&r1=663238&r2=663239&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch.js [utf-8] Wed Jun 4 08:44:17 2008
@@ -87,7 +87,7 @@
var result = JSON.parse(req.responseText);
if (req.status != 201)
throw result;
- for(var i in docs) {
+ for (var i = 0; i < docs.length; i++) {
docs[i]._id = result.new_revs[i].id;
docs[i]._rev = result.new_revs[i].rev;
}
Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=663239&r1=663238&r2=663239&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Wed Jun 4 08:44:17 2008
@@ -190,6 +190,42 @@
}
},
+ bulk_docs: function(debug) {
+ var db = new CouchDB("test_suite_db");
+ db.deleteDb();
+ db.createDb();
+ if (debug) debugger;
+
+ var docs = makeDocs(5);
+
+ // Create the docs
+ var result = db.bulkSave(docs);
+ T(result.ok);
+ T(result.new_revs.length == 5);
+ for (var i = 0; i < 5; i++) {
+ T(result.new_revs[i].id == docs[i]._id);
+ T(result.new_revs[i].rev);
+ docs[i].string = docs[i].string + ".00";
+ }
+
+ // Update the docs
+ result = db.bulkSave(docs);
+ T(result.ok);
+ T(result.new_revs.length == 5);
+ for (i = 0; i < 5; i++) {
+ T(result.new_revs[i].id == i.toString());
+ docs[i]._deleted = true;
+ }
+
+ // Delete the docs
+ result = db.bulkSave(docs);
+ T(result.ok);
+ T(result.new_revs.length == 5);
+ for (i = 0; i < 5; i++) {
+ T(db.open(docs[i]._id) == null);
+ }
+ },
+
// test saving a semi-large quanitity of documents and do some view queries.
lots_of_docs: function(debug) {
var db = new CouchDB("test_suite_db");
@@ -1034,8 +1070,12 @@
function makeDocs(start, end, templateDoc) {
var templateDocSrc = templateDoc ? templateDoc.toSource() : "{}"
+ if (end === undefined) {
+ end = start;
+ start = 0;
+ }
var docs = []
- for(var i=start; i<end; i++) {
+ for (var i = start; i < end; i++) {
var newDoc = eval("(" + templateDocSrc + ")");
newDoc._id = (i).toString();
newDoc.integer = i