summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2015-06-27 00:07:57 +0200
committerJan Lehnardt <jan@apache.org>2015-12-12 15:23:25 +0100
commit8fc4eccea53bc55c98a74ec9f4bcec1d98e8bedf (patch)
treef9c6803a5271aac4ce3f1eee72b8cfa2effbc3e2
parent9543d8267eaded5ab908da60a8e89280e2685c46 (diff)
downloadcouchdb-8fc4eccea53bc55c98a74ec9f4bcec1d98e8bedf.tar.gz
wip
-rw-r--r--test/javascript/couch.js2
-rw-r--r--test/javascript/couch_test_runner.js8
-rw-r--r--test/javascript/tests/attachment_names.js18
-rw-r--r--test/javascript/tests/attachments.js15
4 files changed, 32 insertions, 11 deletions
diff --git a/test/javascript/couch.js b/test/javascript/couch.js
index 02722a2d6..edcf393c3 100644
--- a/test/javascript/couch.js
+++ b/test/javascript/couch.js
@@ -423,6 +423,8 @@ 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));
req.open(method, uri, false);
if (options.headers) {
var headers = options.headers;
diff --git a/test/javascript/couch_test_runner.js b/test/javascript/couch_test_runner.js
index efc4dc242..c8e572071 100644
--- a/test/javascript/couch_test_runner.js
+++ b/test/javascript/couch_test_runner.js
@@ -463,3 +463,11 @@ CouchDB.prepareUserDoc = function(user_doc, new_password) {
}
return user_doc;
};
+
+function get_random_db_name() {
+ return "test_suite_db_"
+ + Math.random()
+ .toString(36)
+ .replace(/[^a-z]+/g, '')
+ .substr(0, 8);
+}
diff --git a/test/javascript/tests/attachment_names.js b/test/javascript/tests/attachment_names.js
index c9a5fcce3..89ce3e907 100644
--- a/test/javascript/tests/attachment_names.js
+++ b/test/javascript/tests/attachment_names.js
@@ -11,8 +11,8 @@
// the License.
couchTests.attachment_names = 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"});
db.createDb();
if (debug) debugger;
@@ -29,7 +29,7 @@ couchTests.attachment_names = function(debug) {
var save_response = db.save(goodDoc);
T(save_response.ok);
- var xhr = CouchDB.request("GET", "/test_suite_db/good_doc/Колян.txt");
+ var xhr = CouchDB.request("GET", "/" + db_name + "/good_doc/Колян.txt");
T(xhr.responseText == "This is a base64 encoded text");
T(xhr.getResponseHeader("Content-Type") == "application/octet-stream");
TEquals("\"aEI7pOYCRBLTRQvvqYrrJQ==\"", xhr.getResponseHeader("Etag"));
@@ -37,7 +37,7 @@ couchTests.attachment_names = function(debug) {
var binAttDoc = {
_id: "bin_doc",
_attachments:{
- "foo\x80txt": {
+ "footxt": {
content_type:"text/plain",
data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
}
@@ -53,7 +53,7 @@ couchTests.attachment_names = function(debug) {
var bin_data = "JHAPDO*AU£PN ){(3u[d 93DQ9¡€])} ææøo'∂ƒæ≤çæππ•¥∫¶®#†π¶®¥π€ª®˙π8np";
- var xhr = (CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment\x80txt", {
+ var xhr = (CouchDB.request("PUT", "/" + db_name + "/bin_doc3/attachmenttxt", {
headers:{"Content-Type":"text/plain;charset=utf-8"},
body:bin_data
}));
@@ -64,10 +64,14 @@ couchTests.attachment_names = function(debug) {
// bulk docs
var docs = { docs: [binAttDoc] };
-
- var xhr = CouchDB.request("POST", "/test_suite_db/_bulk_docs", {
+ console.log(JSON.stringify(docs, null, 2));
+ var xhr = CouchDB.request("POST", "/" + db_name + "/_bulk_docs", {
body: JSON.stringify(docs)
});
+ console.log(JSON.stringify(xhr.status, null, 2));
+ console.log(JSON.stringify(xhr.responseText, null, 2));
+ console.log(JSON.stringify(xhr.headers, null, 2));
+
TEquals(201, xhr.status, "attachment_name: bulk docs");
diff --git a/test/javascript/tests/attachments.js b/test/javascript/tests/attachments.js
index 2fa08ee25..41a826ae8 100644
--- a/test/javascript/tests/attachments.js
+++ b/test/javascript/tests/attachments.js
@@ -214,8 +214,11 @@ couchTests.attachments= function(debug) {
// test large attachments - COUCHDB-366
- var lorem = CouchDB.request("GET", "/_utils/script/test/lorem.txt").responseText;
-
+ var lorem = CouchDB.request("GET", "/_utils/test/lorem.txt").responseText;
+ console.log('lorem');
+ console.log(lorem);
+ console.log('end lorem');
+
var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc5/lorem.txt", {
headers:{"Content-Type":"text/plain;charset=utf-8"},
body:lorem
@@ -228,9 +231,13 @@ couchTests.attachments= function(debug) {
TEqualsIgnoreCase("text/plain;charset=utf-8", xhr.getResponseHeader("Content-Type"));
// test large inline attachment too
- var lorem_b64 = CouchDB.request("GET", "/_utils/script/test/lorem_b64.txt").responseText;
+ var lorem_b64 = CouchDB.request("GET", "/_utils/test/lorem_b64.txt");
+ console.log(JSON.stringify(lorem_b64, null, 2));
+ console.log(lorem_b64.status);
+ console.log(lorem_b64.responseText);
+ lorem_b64 = lorem_b64.responseText;
var doc = db.open("bin_doc5", {attachments:true});
- T(doc._attachments["lorem.txt"].data == lorem_b64);
+ TEquals(lorem_b64, doc._attachments["lorem.txt"].data, 'binary attachment data should match');
// test etags for attachments.
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc5/lorem.txt");