diff options
author | Adam Kocoloski <adam@cloudant.com> | 2011-08-15 15:45:15 -0400 |
---|---|---|
committer | Adam Kocoloski <adam@cloudant.com> | 2011-08-15 15:45:15 -0400 |
commit | 6ffe1675dd7b004e48891956a6bdbe32899ce80c (patch) | |
tree | 57326d9a498481e65bb0db38c66daf10896801f1 /rel/overlay/share/www/script/test/view_include_docs.js | |
parent | 52ff89ff7996e839b9e2f91fd76184d362a8aeb0 (diff) | |
parent | fdd1a5d0bc48b49b0df5c9217beff9574011283c (diff) |
Merge branch '11554-merge-couchdb-1.1'
Diffstat (limited to 'rel/overlay/share/www/script/test/view_include_docs.js')
-rw-r--r-- | rel/overlay/share/www/script/test/view_include_docs.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/rel/overlay/share/www/script/test/view_include_docs.js b/rel/overlay/share/www/script/test/view_include_docs.js index 06aafc56..944c9103 100644 --- a/rel/overlay/share/www/script/test/view_include_docs.js +++ b/rel/overlay/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(); }; |