You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ra...@apache.org on 2012/01/27 02:37:11 UTC
[1/7] git commit: Fix JS tests for COUCHDB-1338
Updated Branches:
refs/heads/master 7309340cf -> 127cbe36c
Fix JS tests for COUCHDB-1338
Fix two bad assumptions:
- The server restarts on the same port
Change replicator_db test which verifies that replications described
by _replicator documents survive restart to use non-HTTP db references.
- The config port matches the port in the CouchDB request URL.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/127cbe36
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/127cbe36
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/127cbe36
Branch: refs/heads/master
Commit: 127cbe36c279ee46f387143a74613ba546e06e42
Parents: d20e792
Author: Randall Leeds <ra...@apache.org>
Authored: Wed Dec 14 22:52:13 2011 -0800
Committer: Randall Leeds <ra...@apache.org>
Committed: Thu Jan 26 17:03:10 2012 -0800
----------------------------------------------------------------------
share/www/script/couch.js | 13 ++++++++-
share/www/script/test/config.js | 2 +-
share/www/script/test/replicator_db.js | 39 +++++++++++++--------------
3 files changed, 32 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/127cbe36/share/www/script/couch.js
----------------------------------------------------------------------
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index d078d96..f7099e3 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -478,7 +478,18 @@ CouchDB.params = function(options) {
};
// Used by replication test
if (typeof window == 'undefined' || !window) {
- CouchDB.host = "127.0.0.1:5984";
+ var hostRE = RegExp("https?://([^\/]+)");
+ var getter = function () {
+ return (new CouchHTTP).base_url.match(hostRE)[1];
+ };
+ if(Object.defineProperty) {
+ Object.defineProperty(CouchDB, "host", {
+ get : getter,
+ enumerable : true
+ });
+ } else {
+ CouchDB.__defineGetter__("host", getter);
+ }
CouchDB.protocol = "http://";
CouchDB.inBrowser = false;
} else {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/127cbe36/share/www/script/test/config.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/config.js b/share/www/script/test/config.js
index 9e4ae35..5382778 100644
--- a/share/www/script/test/config.js
+++ b/share/www/script/test/config.js
@@ -46,7 +46,7 @@ couchTests.config = function(debug) {
config_port = config.ssl.port;
}
- if(port) {
+ if(port && config_port != "0") {
TEquals(config_port, port, "ports should match");
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/127cbe36/share/www/script/test/replicator_db.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/replicator_db.js b/share/www/script/test/replicator_db.js
index 5eedc10..3795386 100644
--- a/share/www/script/test/replicator_db.js
+++ b/share/www/script/test/replicator_db.js
@@ -15,7 +15,6 @@ couchTests.replicator_db = function(debug) {
if (debug) debugger;
var wait_rep_doc = 500; // number of millisecs to wait after saving a Rep Doc
- var host = CouchDB.host;
var dbA = new CouchDB("test_suite_rep_db_a", {"X-Couch-Full-Commit":"false"});
var dbB = new CouchDB("test_suite_rep_db_b", {"X-Couch-Full-Commit":"false"});
var repDb = new CouchDB("test_suite_rep_db", {"X-Couch-Full-Commit":"false"});
@@ -157,7 +156,7 @@ couchTests.replicator_db = function(debug) {
var repDoc = {
_id: "foo_filt_rep_doc",
- source: "http://" + host + "/" + dbA.name,
+ source: "http://" + CouchDB.host + "/" + dbA.name,
target: dbB.name,
filter: "mydesign/myfilter",
query_params: {
@@ -206,7 +205,7 @@ couchTests.replicator_db = function(debug) {
var repDoc = {
_id: "foo_cont_rep_doc",
- source: "http://" + host + "/" + dbA.name,
+ source: "http://" + CouchDB.host + "/" + dbA.name,
target: dbB.name,
continuous: true,
user_ctx: {
@@ -305,7 +304,7 @@ couchTests.replicator_db = function(debug) {
var repDoc = {
_id: "foo_cont_rep_doc",
- source: "http://" + host + "/" + dbA.name,
+ source: "http://" + CouchDB.host + "/" + dbA.name,
target: dbB.name,
doc_ids: ["foo666", "foo3", "_design/mydesign", "foo999", "foo1"]
};
@@ -435,12 +434,12 @@ couchTests.replicator_db = function(debug) {
var repDoc1 = {
_id: "foo_dup_rep_doc_1",
- source: "http://" + host + "/" + dbA.name,
+ source: "http://" + CouchDB.host + "/" + dbA.name,
target: dbB.name
};
var repDoc2 = {
_id: "foo_dup_rep_doc_2",
- source: "http://" + host + "/" + dbA.name,
+ source: "http://" + CouchDB.host + "/" + dbA.name,
target: dbB.name
};
@@ -477,13 +476,13 @@ couchTests.replicator_db = function(debug) {
var repDoc1 = {
_id: "foo_dup_cont_rep_doc_1",
- source: "http://" + host + "/" + dbA.name,
+ source: "http://" + CouchDB.host + "/" + dbA.name,
target: dbB.name,
continuous: true
};
var repDoc2 = {
_id: "foo_dup_cont_rep_doc_2",
- source: "http://" + host + "/" + dbA.name,
+ source: "http://" + CouchDB.host + "/" + dbA.name,
target: dbB.name,
continuous: true
};
@@ -663,7 +662,7 @@ couchTests.replicator_db = function(debug) {
var repDoc = {
_id: "foo_cont_rep_survives_doc",
- source: "http://" + host + "/" + dbA.name,
+ source: dbA.name,
target: dbB.name,
continuous: true
};
@@ -805,7 +804,7 @@ couchTests.replicator_db = function(debug) {
var repDoc = {
_id: "foo_rep",
- source: CouchDB.protocol + host + "/" + dbA.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
target: dbB.name
};
@@ -901,7 +900,7 @@ couchTests.replicator_db = function(debug) {
repDoc = {
_id: "foo_rep_2",
- source: CouchDB.protocol + host + "/" + dbA.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
target: dbB.name,
user_ctx: {
name: "joe",
@@ -949,7 +948,7 @@ couchTests.replicator_db = function(debug) {
repDoc = {
_id: "foo_rep_3",
- source: CouchDB.protocol + host + "/" + dbA.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
target: dbB.name
};
@@ -968,7 +967,7 @@ couchTests.replicator_db = function(debug) {
repDoc = {
_id: "foo_rep_4",
- source: CouchDB.protocol + host + "/" + dbA.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
target: dbB.name,
user_ctx: {
roles: ["_admin"]
@@ -1043,19 +1042,19 @@ couchTests.replicator_db = function(debug) {
repDoc1 = {
_id: "rep1",
- source: CouchDB.protocol + host + "/" + dbA.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
target: dbA_copy.name,
continuous: true
};
repDoc2 = {
_id: "rep2",
- source: CouchDB.protocol + host + "/" + dbB.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbB.name,
target: dbB_copy.name,
continuous: true
};
repDoc3 = {
_id: "rep3",
- source: CouchDB.protocol + host + "/" + dbC.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbC.name,
target: dbC_copy.name,
continuous: true
};
@@ -1144,13 +1143,13 @@ couchTests.replicator_db = function(debug) {
repDoc1 = {
_id: "rep1",
- source: CouchDB.protocol + host + "/" + dbA.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
target: dbA_copy.name,
continuous: true
};
repDoc2 = {
_id: "rep2",
- source: CouchDB.protocol + host + "/" + dbB.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbB.name,
target: dbB_copy.name,
continuous: true
};
@@ -1413,12 +1412,12 @@ couchTests.replicator_db = function(debug) {
repDoc1 = {
_id: "rep1",
- source: CouchDB.protocol + host + "/" + dbA.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
target: dbA_copy.name
};
repDoc2 = {
_id: "rep2",
- source: CouchDB.protocol + host + "/" + dbB.name,
+ source: CouchDB.protocol + CouchDB.host + "/" + dbB.name,
target: dbB_copy.name
};