summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2011-02-10 08:31:49 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2011-02-10 08:31:49 +0000
commitf8b7288dce60a15136583483b533eb9a7c101b64 (patch)
tree1e91cdff6f6048cfa59f6dd215e7b2b0ee41bdeb /share
parent4158b51580cb27cbe143384f1ca41ac18c9ea0cb (diff)
Merged revision 1069268 from trunk
Added more tests to all_docs.js git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1069270 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/www/script/test/all_docs.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/share/www/script/test/all_docs.js b/share/www/script/test/all_docs.js
index ab443605..910d4462 100644
--- a/share/www/script/test/all_docs.js
+++ b/share/www/script/test/all_docs.js
@@ -86,10 +86,40 @@ couchTests.all_docs = function(debug) {
T(changes.results[2].doc);
T(changes.results[2].doc._deleted);
+ // add conflicts
+ var conflictDoc1 = {
+ _id: "3", _rev: "2-aa01552213fafa022e6167113ed01087", value: "X"
+ };
+ var conflictDoc2 = {
+ _id: "3", _rev: "2-ff01552213fafa022e6167113ed01087", value: "Z"
+ };
+ T(db.save(conflictDoc1, {new_edits: false}));
+ T(db.save(conflictDoc2, {new_edits: false}));
+
+ var winRev = db.open("3");
+
+ changes = db.changes({include_docs: true, style: "all_docs"});
+ TEquals("3", changes.results[3].id);
+ TEquals(3, changes.results[3].changes.length);
+ TEquals(winRev._rev, changes.results[3].changes[0].rev);
+ TEquals("3", changes.results[3].doc._id);
+ TEquals(winRev._rev, changes.results[3].doc._rev);
+
+ rows = db.allDocs({include_docs: true}).rows;
+ TEquals(3, rows.length);
+ TEquals("3", rows[2].key);
+ TEquals("3", rows[2].id);
+ TEquals(winRev._rev, rows[2].value.rev);
+ TEquals(winRev._rev, rows[2].doc._rev);
+ TEquals("3", rows[2].doc._id);
+
// test the all docs collates sanely
db.save({_id: "Z", foo: "Z"});
db.save({_id: "a", foo: "a"});
var rows = db.allDocs({startkey: "Z", endkey: "Z"}).rows;
T(rows.length == 1);
+
+ // cleanup
+ db.deleteDb();
};