Commit 49a12950 authored by Tristan Cavelier's avatar Tristan Cavelier

davstorage test added for allDocs+include_docs

parent 54d630e4
......@@ -879,9 +879,9 @@
return;
}
e.target.response.data.rows.forEach(function (row) {
e.target.response.rows.forEach(function (row) {
requests[requests.length] = that._get({"_id": row.id}).
done(function (e) {
then(function (e) {
row.doc = e.target.response;
});
});
......
......@@ -62,7 +62,7 @@
* X-Requested-With, X-HTTP-Method-Override, Accept, Authorization,
* Depth"
*/
test("Scenario", 32, function () {
test("Scenario", 33, function () {
var server, responses = [], shared = {}, jio = jIO.createJIO(spec, {
"workspace": {},
......@@ -465,6 +465,141 @@
}, "List 2 documents");
}
function listDocumentsWithMetadata() {
responses.push([
207,
{"Content-Type": "text/xml"},
'<?xml version="1.0" encoding="utf-8"?>' +
'<D:multistatus xmlns:D="DAV:">' +
'<D:response xmlns:lp2="http://apache.' +
'org/dav/props/" xmlns:lp1="DAV:">' +
'<D:href>/uploads/</D:href>' +
'<D:propstat>' +
'<D:prop>' +
'<lp1:resourcetype><D:collection/></lp1:resourcetype>' +
'<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
'<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
'</lp1:getlastmodified>' +
'<lp1:getetag>"240be-1000-4e6bb383e5fbb"</lp1:getetag>' +
'<D:supportedlock>' +
'<D:lockentry>' +
'<D:lockscope><D:exclusive/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'<D:lockentry>' +
'<D:lockscope><D:shared/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'</D:supportedlock>' +
'<D:lockdiscovery/>' +
'<D:getcontenttype>httpd/unix-directory</D:getcontenttype>' +
'</D:prop>' +
'<D:status>HTTP/1.1 200 OK</D:status>' +
'</D:propstat>' +
'</D:response>' +
'<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
'xmlns:lp1="DAV:">' +
'<D:href>/uploads/' + shared.created_document_id + '</D:href>' +
'<D:propstat>' +
'<D:prop>' +
'<lp1:resourcetype/>' +
'<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
'<lp1:getcontentlength>66</lp1:getcontentlength>' +
'<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
'</lp1:getlastmodified>' +
'<lp1:getetag>"20529-42-4e6bb383d0d30"</lp1:getetag>' +
'<lp2:executable>F</lp2:executable>' +
'<D:supportedlock>' +
'<D:lockentry>' +
'<D:lockscope><D:exclusive/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'<D:lockentry>' +
'<D:lockscope><D:shared/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'</D:supportedlock>' +
'<D:lockdiscovery/>' +
'</D:prop>' +
'<D:status>HTTP/1.1 200 OK</D:status>' +
'</D:propstat>' +
'</D:response>' +
'<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
'xmlns:lp1="DAV:">' +
'<D:href>/uploads/b</D:href>' +
'<D:propstat>' +
'<D:prop>' +
'<lp1:resourcetype/>' +
'<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
'<lp1:getcontentlength>25</lp1:getcontentlength>' +
'<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
'</lp1:getlastmodified>' +
'<lp1:getetag>"20da3-19-4e6bb383e5fbb"</lp1:getetag>' +
'<lp2:executable>F</lp2:executable>' +
'<D:supportedlock>' +
'<D:lockentry>' +
'<D:lockscope><D:exclusive/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'<D:lockentry>' +
'<D:lockscope><D:shared/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'</D:supportedlock>' +
'<D:lockdiscovery/>' +
'</D:prop>' +
'<D:status>HTTP/1.1 200 OK</D:status>' +
'</D:propstat>' +
'</D:response>' +
'</D:multistatus>'
]); // PROPFIND
responses.push([200, {
"Content-Type": "application/octet-stream"
}, JSON.stringify({
"_id": shared.created_document_id,
"title": "Unique ID"
})]); // GET
responses.push([200, {
"Content-Type": "application/octet-stream"
}, JSON.stringify({
"_id": "b",
"title": "Bee"
})]); // GET
return jio.allDocs({"include_docs": true});
}
function list2DocumentsWithMetadataTest(answer) {
if (answer && answer.data && Array.isArray(answer.data.rows)) {
answer.data.rows.sort(function (a) {
return a.id === "b" ? 1 : 0;
});
}
deepEqual(answer, {
"data": {
"total_rows": 2,
"rows": [{
"id": shared.created_document_id,
"value": {},
"doc": {
"_id": shared.created_document_id,
"title": "Unique ID"
}
}, {
"id": "b",
"value": {},
"doc": {
"_id": "b",
"title": "Bee"
}
}]
},
"method": "allDocs",
"result": "success",
"status": 200,
"statusText": "Ok"
}, "List 2 documents with their metadata");
}
function removeCreatedDocument() {
responses.push([200, {
"Content-Type": "application/octet-stream"
......@@ -1161,6 +1296,8 @@
then(checkStorage).then(checkStorageTest).
// allD 200 2 documents
then(listDocuments).then(list2DocumentsTest).
// allD+include_docs 200 2 documents
then(listDocumentsWithMetadata).then(list2DocumentsWithMetadataTest).
// remove a 204
then(removeCreatedDocument).then(removeCreatedDocumentTest).
// remove b 204
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment