couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1104490 - /couchdb/trunk/share/www/script/test/replication.js
Date Tue, 17 May 2011 19:41:03 GMT
Author: fdmanana
Date: Tue May 17 19:41:02 2011
New Revision: 1104490

URL: http://svn.apache.org/viewvc?rev=1104490&view=rev
Log:
Backport test for COUCHDB-885 from 1.1.x and 1.0.x

Modified:
    couchdb/trunk/share/www/script/test/replication.js

Modified: couchdb/trunk/share/www/script/test/replication.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/replication.js?rev=1104490&r1=1104489&r2=1104490&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/replication.js (original)
+++ couchdb/trunk/share/www/script/test/replication.js Tue May 17 19:41:02 2011
@@ -1471,6 +1471,70 @@ couchTests.replication = function(debug)
   }
 
 
+  // COUCHDB-885 - push replication of a doc with attachment causes a
+  //               conflict in the target.
+  sourceDb = new CouchDB("test_suite_db_a");
+  targetDb = new CouchDB("test_suite_db_b");
+
+  sourceDb.deleteDb();
+  sourceDb.createDb();
+  targetDb.deleteDb();
+  targetDb.createDb();
+
+  doc = {
+    _id: "doc1"
+  };
+  TEquals(true, sourceDb.save(doc).ok);
+
+  repResult = CouchDB.replicate(
+    sourceDb.name,
+    CouchDB.protocol + host + "/" + targetDb.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, sourceDb.save(doc).ok);
+  repResult = CouchDB.replicate(
+    sourceDb.name,
+    CouchDB.protocol + host + "/" + targetDb.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);
+
+  copy = targetDb.open(doc._id, {
+    conflicts: true, deleted_conflicts: true,
+    attachments: true, att_encoding_info: true});
+  T(copy !== null);
+  TEquals("undefined", typeof copy._conflicts);
+  TEquals("undefined", typeof copy._deleted_conflicts);
+  TEquals("text/plain", copy._attachments["hello.txt"]["content_type"]);
+  TEquals("aGVsbG8gd29ybGQ=", copy._attachments["hello.txt"]["data"]);
+  TEquals("gzip", copy._attachments["hello.txt"]["encoding"]);
+  TEquals("not/compressible", copy._attachments["foo.dat"]["content_type"]);
+  TEquals("aSBhbSBub3QgZ3ppcGVk", copy._attachments["foo.dat"]["data"]);
+  TEquals("undefined", typeof copy._attachments["foo.dat"]["encoding"]);
+  // end of test for COUCHDB-885
+
+
   // cleanup
   usersDb.deleteDb();
   sourceDb.deleteDb();



Mime
View raw message