diff options
Diffstat (limited to 'share/www/script/test/update_documents.js')
-rw-r--r-- | share/www/script/test/update_documents.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/share/www/script/test/update_documents.js b/share/www/script/test/update_documents.js index 87fc7352..49d3b68a 100644 --- a/share/www/script/test/update_documents.js +++ b/share/www/script/test/update_documents.js @@ -68,10 +68,13 @@ couchTests.update_documents = function(debug) { "headers" : { "Content-Type" : "application/xml" }, - "body" : xml + "body" : xml.toXMLString() }; return [doc, resp]; + }), + "get-uuid" : stringFun(function(doc, req) { + return [null, req.uuid]; }) } }; @@ -110,9 +113,13 @@ couchTests.update_documents = function(debug) { T(JSON.parse(xhr.responseText).error == "method_not_allowed"); // // hello update world (non-existing docid) + xhr = CouchDB.request("GET", "/test_suite_db/nonExistingDoc"); + T(xhr.status == 404); xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/hello/nonExistingDoc"); T(xhr.status == 201); T(xhr.responseText == "<p>New World</p>"); + xhr = CouchDB.request("GET", "/test_suite_db/nonExistingDoc"); + T(xhr.status == 200); // in place update xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/in-place/"+docid+'?field=title&value=test'); @@ -123,7 +130,7 @@ couchTests.update_documents = function(debug) { // bump counter xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/bump-counter/"+docid, { - headers : {"X-Couch-Full-Commit":"false"} + headers : {"X-Couch-Full-Commit":"true"} }); T(xhr.status == 201); T(xhr.responseText == "<h1>bumped it!</h1>"); @@ -135,12 +142,16 @@ couchTests.update_documents = function(debug) { headers : {"X-Couch-Full-Commit":"true"} }); + var NewRev = xhr.getResponseHeader("X-Couch-Update-NewRev"); doc = db.open(docid); + T(doc['_rev'] == NewRev); + + T(doc.counter == 2); // parse xml xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/xml/"+docid, { - headers : {"X-Couch-Full-Commit":"false"}, + headers : {"X-Couch-Full-Commit":"true"}, "body" : '<xml><foo>bar</foo></xml>' }); T(xhr.status == 201); @@ -148,5 +159,10 @@ couchTests.update_documents = function(debug) { doc = db.open(docid); T(doc.via_xml == "bar"); + + // Server provides UUID when POSTing without an ID in the URL + xhr = CouchDB.request("POST", "/test_suite_db/_design/update/_update/get-uuid/"); + T(xhr.status == 200); + T(xhr.responseText.length == 32); }; |