Commit bbf74f1f authored by Tristan Cavelier's avatar Tristan Cavelier

Update DavStorage and Jio tests

parent 27016e9e
This diff is collapsed.
...@@ -640,20 +640,20 @@ test ('Document load', function () { ...@@ -640,20 +640,20 @@ test ('Document load', function () {
o.mytest = function (message,doc,errprop,errget) { o.mytest = function (message,doc,errprop,errget) {
var server = o.t.sandbox.useFakeServer(); var server = o.t.sandbox.useFakeServer();
server.respondWith ( server.respondWith (
"PROPFIND","https://ca-davstorage:8080/dav/davload/jiotests/file", "PROPFIND","https://ca-davstorage:8080/davload/jiotests/file",
[errprop,{'Content-Type':'text/xml; charset="utf-8"'}, [errprop,{'Content-Type':'text/xml; charset="utf-8"'},
o.davload]); o.davload]);
server.respondWith ( server.respondWith (
"GET","https://ca-davstorage:8080/dav/davload/jiotests/file", "GET","https://ca-davstorage:8080/davload/jiotests/file",
[errget,{},'content']); [errget,{},'content']);
o.f = function (result) { o.f = function (err,val) {
if (result && result.status) { if (err) {
result = undefined; err = err.status;
} }
deepEqual (result,doc,message); deepEqual (err || val,doc,message);
}; };
o.t.spy(o,'f'); o.t.spy(o,'f');
o.jio.loadDocument('file',{success:o.f,error:o.f,max_retry:1}); o.jio.get('file',{max_retry:1},o.f);
o.clock.tick(1000); o.clock.tick(1000);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -676,11 +676,11 @@ test ('Document load', function () { ...@@ -676,11 +676,11 @@ test ('Document load', function () {
// 403 Forbidden // 403 Forbidden
// 404 Not Found // 404 Not Found
// load an inexistant document. // load an inexistant document.
o.mytest ('load inexistant document',undefined,404,404); o.mytest ('load inexistant document',404,404,404);
// load a document. // load a document.
o.mytest ('load document',{name:'file',content:'content', o.mytest ('load document',{_id:'file',content:'content',
last_modified:1335953199000, _last_modified:1335953199000,
creation_date:1335953202000},207,200); _creation_date:1335953202000},207,200);
o.jio.stop(); o.jio.stop();
}); });
...@@ -696,16 +696,16 @@ test ('Document save', function () { ...@@ -696,16 +696,16 @@ test ('Document save', function () {
var server = o.t.sandbox.useFakeServer(); var server = o.t.sandbox.useFakeServer();
server.respondWith ( server.respondWith (
// lastmodified = 7000, creationdate = 5000 // lastmodified = 7000, creationdate = 5000
"PROPFIND","https://ca-davstorage:8080/dav/davsave/jiotests/file", "PROPFIND","https://ca-davstorage:8080/davsave/jiotests/file",
[errnoprop,{'Content-Type':'text/xml; charset="utf-8"'}, [errnoprop,{'Content-Type':'text/xml; charset="utf-8"'},
o.davsave]); o.davsave]);
server.respondWith ( server.respondWith (
"PUT", "PUT",
"https://ca-davstorage:8080/dav/davsave/jiotests/file", "https://ca-davstorage:8080/davsave/jiotests/file",
[errnoput, {'Content-Type':'x-www-form-urlencoded'}, [errnoput, {'Content-Type':'x-www-form-urlencoded'},
'content']); 'content']);
server.respondWith ( server.respondWith (
"GET","https://ca-davstorage:8080/dav/davsave/jiotests/file", "GET","https://ca-davstorage:8080/davsave/jiotests/file",
[errnoprop===207?200:errnoprop,{},'content']); [errnoprop===207?200:errnoprop,{},'content']);
// server.respondWith ("MKCOL","https://ca-davstorage:8080/dav", // server.respondWith ("MKCOL","https://ca-davstorage:8080/dav",
// [200,{},'']); // [200,{},'']);
...@@ -714,16 +714,9 @@ test ('Document save', function () { ...@@ -714,16 +714,9 @@ test ('Document save', function () {
// server.respondWith ("MKCOL", // server.respondWith ("MKCOL",
// "https://ca-davstorage:8080/dav/davsave/jiotests", // "https://ca-davstorage:8080/dav/davsave/jiotests",
// [200,{},'']); // [200,{},'']);
o.f = function (result) { o.f = basic_test_function_generator(o,'value',value,message);
if (result && result.status) {
result = 'fail';
} else {
result = 'done';
}
deepEqual (result,value,message);
};
o.t.spy(o,'f'); o.t.spy(o,'f');
o.jio.saveDocument('file','content',{success:o.f,error:o.f}); o.jio.put({_id:'file',content:'content'},o.f);
o.clock.tick(1000); o.clock.tick(1000);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -749,10 +742,10 @@ test ('Document save', function () { ...@@ -749,10 +742,10 @@ test ('Document save', function () {
// mytest('create path if not exists, and create document', // mytest('create path if not exists, and create document',
// true,201,404); // true,201,404);
// the document does not exist, we want to create it // the document does not exist, we want to create it
o.mytest('create document','done',201,404); o.mytest('create document',{ok:true,id:'file'},201,404);
o.clock.tick(8000); o.clock.tick(8000);
// the document already exists, we want to overwrite it // the document already exists, we want to overwrite it
o.mytest('overwrite document','done',204,207); o.mytest('overwrite document',{ok:true,id:'file'},204,207);
o.jio.stop(); o.jio.stop();
}); });
...@@ -767,28 +760,27 @@ test ('Get Document List', function () { ...@@ -767,28 +760,27 @@ test ('Get Document List', function () {
o.mytest = function (message,metadata_only,value,errnoprop) { o.mytest = function (message,metadata_only,value,errnoprop) {
var server = o.t.sandbox.useFakeServer(); var server = o.t.sandbox.useFakeServer();
server.respondWith ( server.respondWith (
"PROPFIND",'https://ca-davstorage:8080/dav/davlist/jiotests/', "PROPFIND",'https://ca-davstorage:8080/davlist/jiotests/',
[errnoprop,{'Content-Type':'text/xml; charset="utf-8"'}, [errnoprop,{'Content-Type':'text/xml; charset="utf-8"'},
o.davlist]); o.davlist]);
server.respondWith ( server.respondWith (
"GET","https://ca-davstorage:8080/dav/davlist/jiotests/file", "GET","https://ca-davstorage:8080/davlist/jiotests/file",
[200,{},'content']); [200,{},'content']);
server.respondWith ( server.respondWith (
"GET","https://ca-davstorage:8080/dav/davlist/jiotests/memo", "GET","https://ca-davstorage:8080/davlist/jiotests/memo",
[200,{},'content2']); [200,{},'content2']);
o.f = function (result) { o.f = function (err,val) {
if (result && result.status) { if (err) {
result = undefined; result = undefined;
} else { } else {
deepEqual (objectifyDocumentArray(result), deepEqual (objectifyDocumentArray(val.rows),
objectifyDocumentArray(value),message); objectifyDocumentArray(value),message);
return; return;
} }
deepEqual (result, value, message); deepEqual (result, value, message);
}; };
o.t.spy(o,'f'); o.t.spy(o,'f');
o.jio.getDocumentList('.',{success:o.f,error:o.f, o.jio.allDocs({metadata_only:metadata_only},o.f);
metadata_only:metadata_only});
o.clock.tick(1000); o.clock.tick(1000);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -804,16 +796,34 @@ test ('Get Document List', function () { ...@@ -804,16 +796,34 @@ test ('Get Document List', function () {
url:'https://ca-davstorage:8080', url:'https://ca-davstorage:8080',
applicationname:'jiotests'}); applicationname:'jiotests'});
o.mytest('fail to get list',true,undefined,404); o.mytest('fail to get list',true,undefined,404);
o.mytest('getting list',true,[{name:'file',creation_date:1335962911000, o.mytest('getting list',true,[{
last_modified:1335962907000}, id:'file',key:'file',
{name:'memo',creation_date:1335894073000, value:{
last_modified:1335955713000}],207); _creation_date:1335962911000,
o.mytest('getting list',false,[{name:'file',content:'content', _last_modified:1335962907000
creation_date:1335962911000, }
last_modified:1335962907000}, },{
{name:'memo',content:'content2', id:'memo',key:'memo',
creation_date:1335894073000, value:{
last_modified:1335955713000}],207); _creation_date:1335894073000,
_last_modified:1335955713000
}
}],207);
o.mytest('getting list',false,[{
id:'file',key:'file',
value:{
content:'content',
_creation_date:1335962911000,
_last_modified:1335962907000
}
},{
id:'memo',key:'memo',
value:{
content:'content2',
_creation_date:1335894073000,
_last_modified:1335955713000
}
}],207);
o.jio.stop(); o.jio.stop();
}); });
...@@ -825,18 +835,16 @@ test ('Remove document', function () { ...@@ -825,18 +835,16 @@ test ('Remove document', function () {
o.mytest = function (message,value,errnodel) { o.mytest = function (message,value,errnodel) {
var server = o.t.sandbox.useFakeServer(); var server = o.t.sandbox.useFakeServer();
server.respondWith ( server.respondWith (
"DELETE","https://ca-davstorage:8080/dav/davremove/jiotests/file", "DELETE","https://ca-davstorage:8080/davremove/jiotests/file",
[errnodel,{},'']); [errnodel,{},'']);
o.f = function (result) { o.f = function (err,val) {
if (result && result.status) { if (err) {
result = 'fail'; err = err.status;
} else {
result = 'done';
} }
deepEqual (result,value,message); deepEqual (err || val,value,message);
}; };
o.t.spy(o,'f'); o.t.spy(o,'f');
o.jio.removeDocument('file',{success:o.f,error:o.f}); o.jio.remove({_id:'file'},o.f);
o.clock.tick(1000); o.clock.tick(1000);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -850,10 +858,10 @@ test ('Remove document', function () { ...@@ -850,10 +858,10 @@ test ('Remove document', function () {
o.jio = JIO.newJio({type:'dav',username:'davremove', o.jio = JIO.newJio({type:'dav',username:'davremove',
password:'checkpwd', password:'checkpwd',
url:'https://ca-davstorage:8080', url:'https://ca-davstorage:8080',
appliactionname:'jiotests'}); applicationname:'jiotests'});
o.mytest('remove document','done',204); o.mytest('remove document',{ok:true,id:'file'},204);
o.mytest('remove an already removed document','done',404); o.mytest('remove an already removed document',404,404);
o.jio.stop(); o.jio.stop();
}); });
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:"> <D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/"> <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>/dav/davgetlist/jiotests/</D:href> <D:href>/davgetlist/jiotests/</D:href>
<D:propstat> <D:propstat>
<D:prop> <D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype> <lp1:resourcetype><D:collection/></lp1:resourcetype>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</D:propstat> </D:propstat>
</D:response> </D:response>
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/"> <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>/dav/davgetlist/jiotests/file</D:href> <D:href>/davgetlist/jiotests/file</D:href>
<D:propstat> <D:propstat>
<D:prop> <D:prop>
<lp1:resourcetype/> <lp1:resourcetype/>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</D:propstat> </D:propstat>
</D:response> </D:response>
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/"> <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>/dav/davgetlist/jiotests/memo</D:href> <D:href>/davgetlist/jiotests/memo</D:href>
<D:propstat> <D:propstat>
<D:prop> <D:prop>
<lp1:resourcetype/> <lp1:resourcetype/>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:"> <D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/"> <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>/dav/davload/jiotests/file</D:href> <D:href>/davload/jiotests/file</D:href>
<D:propstat> <D:propstat>
<D:prop> <D:prop>
<lp1:resourcetype/> <lp1:resourcetype/>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:"> <D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/"> <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>/dav/davsave/jiotests/file</D:href> <D:href>/davsave/jiotests/file</D:href>
<D:propstat> <D:propstat>
<D:prop> <D:prop>
<lp1:resourcetype/> <lp1:resourcetype/>
......
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