You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2015/12/12 17:01:26 UTC
[05/35] couchdb commit: updated refs/heads/2876-js-tests-merged to
6d9b2eb
make request commits global
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b2bb3b80
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b2bb3b80
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b2bb3b80
Branch: refs/heads/2876-js-tests-merged
Commit: b2bb3b8038fcfbafe1b47d0168191ff1a526649b
Parents: 8fc4ecc
Author: Jan Lehnardt <ja...@apache.org>
Authored: Wed Oct 7 14:34:58 2015 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sat Dec 12 15:23:26 2015 +0100
----------------------------------------------------------------------
test/javascript/couch.js | 27 ++++++++++++++++++++------
test/javascript/tests/all_docs.js | 6 +++---
test/javascript/tests/attachment_names.js | 2 +-
test/javascript/tests/auth_cache.js | 3 ++-
4 files changed, 27 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b2bb3b80/test/javascript/couch.js
----------------------------------------------------------------------
diff --git a/test/javascript/couch.js b/test/javascript/couch.js
index edcf393..2eab915 100644
--- a/test/javascript/couch.js
+++ b/test/javascript/couch.js
@@ -13,7 +13,8 @@
// A simple class to represent a database. Uses XMLHttpRequest to interface with
// the CouchDB server.
-function CouchDB(name, httpHeaders) {
+function CouchDB(name, httpHeaders, globalRequestOptions) {
+ this.globalRequestOptions = globalRequestOptions || {}
this.name = name;
this.uri = "/" + encodeURIComponent(name) + "/";
@@ -24,6 +25,7 @@ function CouchDB(name, httpHeaders) {
this.request = function(method, uri, requestOptions) {
requestOptions = requestOptions || {};
requestOptions.headers = combine(requestOptions.headers, httpHeaders);
+ requestOptions.url = globalRequestOptions;
return CouchDB.request(method, uri, requestOptions);
};
@@ -71,10 +73,9 @@ function CouchDB(name, httpHeaders) {
};
// Deletes a document from the database
- this.deleteDoc = function(doc, request_options) {
- request_options = request_options || "";
+ this.deleteDoc = function(doc) {
this.last_req = this.request("DELETE", this.uri + encodeURIComponent(doc._id)
- + "?rev=" + doc._rev + request_options);
+ + "?rev=" + doc._rev);
CouchDB.maybeThrowError(this.last_req);
var result = JSON.parse(this.last_req.responseText);
doc._rev = result.rev; //record rev in input document
@@ -423,8 +424,22 @@ CouchDB.request = function(method, uri, options) {
options.headers["Accept"] = options.headers["Accept"] || options.headers["accept"] || "application/json";
var req = CouchDB.newXhr();
uri = CouchDB.proxyUrl(uri);
- console.log(uri);
- console.log(JSON.stringify(options, null, 2));
+
+ if (options.url) {
+ var params = '';
+ for (var key in options.url) {
+ var value = options.url[key]
+ params += key + '=' + value + '&'
+ }
+ // if uri already has a ? append with &
+ if (uri.indexOf('?') === -1) {
+ uri += '?' + params;
+ } else {
+ uri += '&' + params;
+ }
+ }
+ // console.log(uri);
+ // console.log(JSON.stringify(options, null, 2));
req.open(method, uri, false);
if (options.headers) {
var headers = options.headers;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b2bb3b80/test/javascript/tests/all_docs.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/all_docs.js b/test/javascript/tests/all_docs.js
index bc6639b..5e4e8d1 100644
--- a/test/javascript/tests/all_docs.js
+++ b/test/javascript/tests/all_docs.js
@@ -11,8 +11,8 @@
// the License.
couchTests.all_docs = function(debug) {
- var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
- db.deleteDb();
+ var db_name = get_random_db_name();
+ var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}, {w: 3});
db.createDb();
if (debug) debugger;
@@ -70,7 +70,7 @@ couchTests.all_docs = function(debug) {
// check that deletions also show up right
var doc1 = db.open("1");
- var deleted = db.deleteDoc(doc1, "&w=3");
+ var deleted = db.deleteDoc(doc1);
T(deleted.ok);
changes = db.changes();
T(changes.results.length == 4);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b2bb3b80/test/javascript/tests/attachment_names.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/attachment_names.js b/test/javascript/tests/attachment_names.js
index 89ce3e9..b0d827a 100644
--- a/test/javascript/tests/attachment_names.js
+++ b/test/javascript/tests/attachment_names.js
@@ -12,7 +12,7 @@
couchTests.attachment_names = function(debug) {
var db_name = get_random_db_name();
- var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+ var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}, {w: 3});
db.createDb();
if (debug) debugger;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b2bb3b80/test/javascript/tests/auth_cache.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/auth_cache.js b/test/javascript/tests/auth_cache.js
index 39b9887..2151ddb 100644
--- a/test/javascript/tests/auth_cache.js
+++ b/test/javascript/tests/auth_cache.js
@@ -25,7 +25,8 @@ couchTests.auth_cache = function(debug) {
return secret;
}
- var authDb = new CouchDB("test_suite_users", {"X-Couch-Full-Commit":"false"});
+ var db_name = get_random_db_name();
+ var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}, {w: 3});
var server_config = [
{
section: "couch_httpd_auth",