summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2008-07-17 18:52:46 +0000
committerJan Lehnardt <jan@apache.org>2008-07-17 18:52:46 +0000
commit48bed8e9d4d898708df8ebcb76c3db3ce64e1a2d (patch)
tree47e7d92dab53e12f7d3d847534d534e1cb1e7ec0 /share
parent724d837ea4e009e5f3867d2e89f91b9e95ca75a1 (diff)
Allow for empty attachments.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@677682 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/www/script/couch_tests.js44
1 files changed, 43 insertions, 1 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 6a1e72c8..c65e98b5 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -558,7 +558,25 @@ var tests = {
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
T(xhr.responseText == "This is a base64 encoded text");
T(xhr.getResponseHeader("Content-Type") == "text/plain");
-
+
+
+ // empty attachment
+ var binAttDoc2 = {
+ _id: "bin_doc5",
+ _attachments:{
+ "foo.txt": {
+ content_type:"text/plain",
+ data: ""
+ }
+ }
+ }
+
+ T(db.save(binAttDoc2).ok);
+
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc5/foo.txt");
+ T(xhr.responseText.length == 0);
+ T(xhr.getResponseHeader("Content-Type") == "text/plain");
+
// test RESTful doc API
var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc2/foo2.txt", {
@@ -620,6 +638,30 @@ var tests = {
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev);
T(xhr.status == 404);
+
+ // empty attachments
+ var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc4/attachment.txt", {
+ headers:{"Content-Type":"text/plain;charset=utf-8"},
+ body:""
+ });
+ T(xhr.status == 201);
+ var rev = JSON.parse(xhr.responseText).rev;
+
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt");
+ T(xhr.status == 200);
+ T(xhr.responseText.length == 0);
+
+ // overwrite previsously empty attachment
+ var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc4/attachment.txt?rev=" + rev, {
+ headers:{"Content-Type":"text/plain;charset=utf-8"},
+ body:"This is a string"
+ });
+ T(xhr.status == 201);
+
+ var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt");
+ T(xhr.status == 200);
+ T(xhr.responseText == "This is a string");
+
},
content_negotiation: function(debug) {