diff options
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/test/all_docs.js | 8 | ||||
-rw-r--r-- | share/www/script/test/view_include_docs.js | 54 |
2 files changed, 60 insertions, 2 deletions
diff --git a/share/www/script/test/all_docs.js b/share/www/script/test/all_docs.js index 4324e3bb..1d83aa95 100644 --- a/share/www/script/test/all_docs.js +++ b/share/www/script/test/all_docs.js @@ -105,20 +105,24 @@ couchTests.all_docs = function(debug) { var winRev = db.open("3"); - changes = db.changes({include_docs: true, style: "all_docs"}); + changes = db.changes({include_docs: true, conflicts: 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); + TEquals(true, changes.results[3].doc._conflicts instanceof Array); + TEquals(2, changes.results[3].doc._conflicts.length); - rows = db.allDocs({include_docs: true}).rows; + rows = db.allDocs({include_docs: true, conflicts: 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); + TEquals(true, rows[2].doc._conflicts instanceof Array); + TEquals(2, rows[2].doc._conflicts.length); // test the all docs collates sanely db.save({_id: "Z", foo: "Z"}); diff --git a/share/www/script/test/view_include_docs.js b/share/www/script/test/view_include_docs.js index 06aafc56..944c9103 100644 --- a/share/www/script/test/view_include_docs.js +++ b/share/www/script/test/view_include_docs.js @@ -135,4 +135,58 @@ couchTests.view_include_docs = function(debug) { T(!resp.rows[0].doc); T(resp.rows[0].doc == null); T(resp.rows[1].doc.integer == 23); + + // COUCHDB-549 - include_docs=true with conflicts=true + + var dbA = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"}); + var dbB = new CouchDB("test_suite_db_b", {"X-Couch-Full-Commit":"false"}); + + dbA.deleteDb(); + dbA.createDb(); + dbB.deleteDb(); + dbB.createDb(); + + var ddoc = { + _id: "_design/mydesign", + language : "javascript", + views : { + myview : { + map: (function(doc) { + emit(doc.value, 1); + }).toString() + } + } + }; + TEquals(true, dbA.save(ddoc).ok); + + var doc1a = {_id: "foo", value: 1, str: "1"}; + TEquals(true, dbA.save(doc1a).ok); + + var doc1b = {_id: "foo", value: 1, str: "666"}; + TEquals(true, dbB.save(doc1b).ok); + + var doc2 = {_id: "bar", value: 2, str: "2"}; + TEquals(true, dbA.save(doc2).ok); + + TEquals(true, CouchDB.replicate(dbA.name, dbB.name).ok); + + doc1b = dbB.open("foo", {conflicts: true}); + TEquals(true, doc1b._conflicts instanceof Array); + TEquals(1, doc1b._conflicts.length); + var conflictRev = doc1b._conflicts[0]; + + doc2 = dbB.open("bar", {conflicts: true}); + TEquals("undefined", typeof doc2._conflicts); + + resp = dbB.view("mydesign/myview", {include_docs: true, conflicts: true}); + + TEquals(2, resp.rows.length); + TEquals(true, resp.rows[0].doc._conflicts instanceof Array); + TEquals(1, resp.rows[0].doc._conflicts.length); + TEquals(conflictRev, resp.rows[0].doc._conflicts[0]); + TEquals("undefined", typeof resp.rows[1].doc._conflicts); + + // cleanup + dbA.deleteDb(); + dbB.deleteDb(); }; |