summaryrefslogtreecommitdiff
path: root/share/www
diff options
context:
space:
mode:
Diffstat (limited to 'share/www')
-rw-r--r--share/www/script/couch.js5
-rw-r--r--share/www/script/test/replication.js24
2 files changed, 28 insertions, 1 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index f6c1199a..86465c95 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -387,9 +387,12 @@ CouchDB.getVersion = function() {
CouchDB.replicate = function(source, target, rep_options) {
rep_options = rep_options || {};
var headers = rep_options.headers || {};
+ var body = rep_options.body || {};
+ body.source = source;
+ body.target = target;
CouchDB.last_req = CouchDB.request("POST", "/_replicate", {
headers: headers,
- body: JSON.stringify({source: source, target: target})
+ body: JSON.stringify(body)
});
CouchDB.maybeThrowError(CouchDB.last_req);
return JSON.parse(CouchDB.last_req.responseText);
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index 210ffa2c..78678937 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -277,4 +277,28 @@ couchTests.replication = function(debug) {
T(result2.no_changes == true);
T(result2.session_id == result.session_id);
}
+
+ // test optional automatic creation of the target db
+
+ 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();
+
+ // local
+ CouchDB.replicate(dbA.name, "test_suite_db_b", {
+ body: {"create_target": true}
+ });
+ TEquals("test_suite_db_b", dbB.info().db_name,
+ "Target database should exist");
+
+ // remote
+ dbB.deleteDb();
+ CouchDB.replicate(dbA.name, "http://" + CouchDB.host + "/test_suite_db_b", {
+ body: {"create_target": true}
+ });
+ TEquals("test_suite_db_b", dbB.info().db_name,
+ "Target database should exist");
};