summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2011-05-17 19:13:42 +0000
committerRobert Newson <rnewson@apache.org>2011-05-17 19:13:42 +0000
commit571edb05e32a2ae70ca7e1b1086ba937d2941a66 (patch)
treeb995befe6c7be0c9361786a3a47f2130417d37bb /share/www/script
parent8730a6d78cd024783f3060d206cf5b8a922d3ce5 (diff)
port Filipe's fix and test for COUCHDB-885 to 1.1.x
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1104475 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/test/replication.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index 7f92891e..bde4ad11 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -785,6 +785,62 @@ couchTests.replication = function(debug) {
TEquals('string', typeof repResult._local_id);
+ // COUCHDB-885 - push replication of a doc with attachment causes a
+ // conflict in the target.
+ dbA = new CouchDB("test_suite_db_a");
+ dbB = new CouchDB("test_suite_db_b");
+
+ dbA.deleteDb();
+ dbA.createDb();
+ dbB.deleteDb();
+ dbB.createDb();
+
+ var doc = {
+ _id: "doc1"
+ };
+ TEquals(true, dbA.save(doc).ok);
+
+ repResult = CouchDB.replicate(
+ dbA.name,
+ CouchDB.protocol + host + "/" + dbB.name
+ );
+ TEquals(true, repResult.ok);
+ TEquals(true, repResult.history instanceof Array);
+ TEquals(1, repResult.history.length);
+ TEquals(1, repResult.history[0].docs_written);
+ TEquals(1, repResult.history[0].docs_read);
+ TEquals(0, repResult.history[0].doc_write_failures);
+
+ doc["_attachments"] = {
+ "hello.txt": {
+ "content_type": "text/plain",
+ "data": "aGVsbG8gd29ybGQ=" // base64:encode("hello world")
+ },
+ "foo.dat": {
+ "content_type": "not/compressible",
+ "data": "aSBhbSBub3QgZ3ppcGVk" // base64:encode("i am not gziped")
+ }
+ };
+
+ TEquals(true, dbA.save(doc).ok);
+ repResult = CouchDB.replicate(
+ dbA.name,
+ CouchDB.protocol + host + "/" + dbB.name
+ );
+ TEquals(true, repResult.ok);
+ TEquals(true, repResult.history instanceof Array);
+ TEquals(2, repResult.history.length);
+ TEquals(1, repResult.history[0].docs_written);
+ TEquals(1, repResult.history[0].docs_read);
+ TEquals(0, repResult.history[0].doc_write_failures);
+
+ var copy = dbB.open(doc._id, {conflicts: true, deleted_conflicts: true});
+ T(copy !== null);
+ TEquals("undefined", typeof copy._conflicts);
+ TEquals("undefined", typeof copy._deleted_conflicts);
+ // end of test for COUCHDB-885
+
+
// cleanup
dbA.deleteDb();
dbB.deleteDb();