couchdb-harness
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -20,5 +20,3 @@ "use strict"; | ||
var blacklist = [ | ||
'javascript/tests/attachment_names.js', | ||
'javascript/tests/attachment_ranges.js', | ||
'javascript/tests/attachments.js', | ||
'javascript/tests/attachments_multipart.js', | ||
@@ -25,0 +23,0 @@ 'javascript/tests/auth_cache.js', |
@@ -86,9 +86,11 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
try { | ||
db.save(binAttDoc); | ||
TEquals(1, 2, "Attachment name with leading underscore saved. Should never show!"); | ||
} catch (e) { | ||
TEquals("bad_request", e.error, "attachment_name: leading underscore"); | ||
TEquals("Attachment name can't start with '_'", e.reason, "attachment_name: leading underscore"); | ||
} | ||
skip('Attachment names with a leading underscore are allowed in PouchDB Server ()', function () { | ||
try { | ||
db.save(binAttDoc); | ||
TEquals(1, 2, "Attachment name with leading underscore saved. Should never show!"); | ||
} catch (e) { | ||
TEquals("bad_request", e.error, "attachment_name: leading underscore"); | ||
TEquals("Attachment name can't start with '_'", e.reason, "attachment_name: leading underscore"); | ||
} | ||
}); | ||
@@ -95,0 +97,0 @@ // todo: form uploads, waiting for cmlenz' test case for form uploads |
@@ -143,7 +143,9 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
// deleted attachment is still accessible with revision | ||
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev); | ||
T(xhr.status == 200); | ||
T(xhr.responseText == bin_data); | ||
TEqualsIgnoreCase("text/plain;charset=utf-8", xhr.getResponseHeader("Content-Type")); | ||
skip("deleted PouchDB Server attachments aren't still accessable with a revision", function () { | ||
// deleted attachment is still accessible with revision | ||
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev); | ||
T(xhr.status == 200); | ||
T(xhr.responseText == bin_data); | ||
TEqualsIgnoreCase("text/plain;charset=utf-8", xhr.getResponseHeader("Content-Type")); | ||
}); | ||
@@ -206,11 +208,15 @@ // empty attachments | ||
T(db.compact().ok); | ||
T(db.last_req.status == 202); | ||
// compaction isn't instantaneous, loop until done | ||
while (db.info().compact_running) {}; | ||
skip("PouchDB Server compaction waits until compaction is done, which is a bug.", function () { | ||
T(db.last_req.status == 202); | ||
// compaction isn't instantaneous, loop until done | ||
while (db.info().compact_running) {}; | ||
}) | ||
var after = db.info().disk_size; | ||
skip("compact doesn't guarantee a leveldb compact so disk size assertions may/will fail", function () { | ||
var after = db.info().disk_size; | ||
// Compaction should reduce the database slightly, but not | ||
// orders of magnitude (unless attachments introduce sparseness) | ||
T(after > before * 0.1, "before: " + before + " after: " + after); | ||
// Compaction should reduce the database slightly, but not | ||
// orders of magnitude (unless attachments introduce sparseness) | ||
T(after > before * 0.1, "before: " + before + " after: " + after); | ||
}); | ||
@@ -232,6 +238,10 @@ | ||
// test large inline attachment too | ||
var lorem_b64 = CouchDB.request("GET", "/_utils/script/test/lorem_b64.txt").responseText; | ||
var doc = db.open("bin_doc5", {attachments:true}); | ||
T(doc._attachments["lorem.txt"].data == lorem_b64); | ||
skip("/_utils/script/test/lorem_b64 doesn't exist on PouchDB-Server", function () { | ||
// test large inline attachment too | ||
var lorem_b64 = CouchDB.request("GET", "/_utils/script/test/lorem_b64.txt").responseText; | ||
var doc = db.open("bin_doc5", {attachments:true}); | ||
console.log(doc._attachments["lorem.txt"].data); | ||
console.log(lorum_b64); | ||
T(doc._attachments["lorem.txt"].data == lorem_b64); | ||
}); | ||
@@ -266,67 +276,74 @@ // test etags for attachments. | ||
// test COUCHDB-809 - stubs should only require the 'stub' field | ||
var bin_doc6 = { | ||
_id: "bin_doc6", | ||
_attachments:{ | ||
"foo.txt": { | ||
content_type:"text/plain", | ||
data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=" | ||
skip("PouchDB bug! 'TypeError: key must be a string but Got undefined'", function () { | ||
// test COUCHDB-809 - stubs should only require the 'stub' field | ||
var bin_doc6 = { | ||
_id: "bin_doc6", | ||
_attachments:{ | ||
"foo.txt": { | ||
content_type:"text/plain", | ||
data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=" | ||
} | ||
} | ||
}; | ||
T(db.save(bin_doc6).ok); | ||
// stub out the attachment | ||
bin_doc6._attachments["foo.txt"] = { stub: true }; | ||
T(db.save(bin_doc6).ok == true); | ||
// wrong rev pos specified | ||
// stub out the attachment with the wrong revpos | ||
bin_doc6._attachments["foo.txt"] = { stub: true, revpos: 10}; | ||
try { | ||
T(db.save(bin_doc6).ok == true); | ||
T(false && "Shouldn't get here!"); | ||
} catch (e) { | ||
T(e.error == "missing_stub"); | ||
} | ||
}; | ||
T(db.save(bin_doc6).ok); | ||
// stub out the attachment | ||
bin_doc6._attachments["foo.txt"] = { stub: true }; | ||
T(db.save(bin_doc6).ok == true); | ||
}) | ||
// wrong rev pos specified | ||
// stub out the attachment with the wrong revpos | ||
bin_doc6._attachments["foo.txt"] = { stub: true, revpos: 10}; | ||
try { | ||
T(db.save(bin_doc6).ok == true); | ||
T(false && "Shouldn't get here!"); | ||
} catch (e) { | ||
T(e.error == "missing_stub"); | ||
} | ||
// test MD5 header | ||
skip("PouchDB server doesn't support Content-MD5 headers", function () { | ||
var bin_data = "foo bar" | ||
var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc7/attachment.txt", { | ||
headers:{"Content-Type":"application/octet-stream", | ||
"Content-MD5":"MntvB0NYESObxH4VRDUycw=="}, | ||
body:bin_data | ||
}); | ||
TEquals(201, xhr.status); | ||
// test MD5 header | ||
var bin_data = "foo bar" | ||
var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc7/attachment.txt", { | ||
headers:{"Content-Type":"application/octet-stream", | ||
"Content-MD5":"MntvB0NYESObxH4VRDUycw=="}, | ||
body:bin_data | ||
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc7/attachment.txt"); | ||
TEquals('MntvB0NYESObxH4VRDUycw==', xhr.getResponseHeader("Content-MD5")); | ||
}); | ||
TEquals(201, xhr.status); | ||
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc7/attachment.txt"); | ||
TEquals('MntvB0NYESObxH4VRDUycw==', xhr.getResponseHeader("Content-MD5")); | ||
// test attachment via multipart/form-data | ||
var bin_doc8 = { | ||
_id: "bin_doc8" | ||
}; | ||
T(db.save(bin_doc8).ok); | ||
var doc = db.open("bin_doc8"); | ||
var body = "------TF\r\n" + | ||
"Content-Disposition: form-data; name=\"_rev\"\r\n\r\n" + | ||
doc._rev + "\r\n" + | ||
"------TF\r\n" + | ||
"Content-Disposition: form-data; name=\"_attachments\"; filename=\"file.txt\"\r\n" + | ||
"Content-Type: text/plain\r\n\r\n" + | ||
"contents of file.txt\r\n\r\n" + | ||
"------TF--" | ||
xhr = CouchDB.request("POST", "/test_suite_db/bin_doc8", { | ||
headers: { | ||
"Content-Type": "multipart/form-data; boundary=----TF", | ||
"Content-Length": body.length | ||
}, | ||
body: body | ||
skip("PouchDB server doesn't have a POST /db/doc route", function () { | ||
// test attachment via multipart/form-data | ||
var bin_doc8 = { | ||
_id: "bin_doc8" | ||
}; | ||
T(db.save(bin_doc8).ok); | ||
var doc = db.open("bin_doc8"); | ||
var body = "------TF\r\n" + | ||
"Content-Disposition: form-data; name=\"_rev\"\r\n\r\n" + | ||
doc._rev + "\r\n" + | ||
"------TF\r\n" + | ||
"Content-Disposition: form-data; name=\"_attachments\"; filename=\"file.txt\"\r\n" + | ||
"Content-Type: text/plain\r\n\r\n" + | ||
"contents of file.txt\r\n\r\n" + | ||
"------TF--" | ||
xhr = CouchDB.request("POST", "/test_suite_db/bin_doc8", { | ||
headers: { | ||
"Content-Type": "multipart/form-data; boundary=----TF", | ||
"Content-Length": body.length | ||
}, | ||
body: body | ||
}); | ||
TEquals(201, xhr.status); | ||
TEquals(true, JSON.parse(xhr.responseText).ok); | ||
var doc = db.open("bin_doc8"); | ||
T(doc._attachments); | ||
T(doc._attachments['file.txt']); | ||
}); | ||
TEquals(201, xhr.status); | ||
TEquals(true, JSON.parse(xhr.responseText).ok); | ||
var doc = db.open("bin_doc8"); | ||
T(doc._attachments); | ||
T(doc._attachments['file.txt']); | ||
}; |
{ | ||
"name": "couchdb-harness", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A generalized port of the CouchDB JavaScript test harness.", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
747696
16129
2