Commit 9d672f03 authored by Tristan Cavelier's avatar Tristan Cavelier

Updating Dummy Storages

parent 1f289bc7
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
// Tells us that the document is saved. // Tells us that the document is saved.
setTimeout (function () { setTimeout (function () {
that.done(); that.success ();
}, 100); }, 100); // 100 ms, for jiotests simple job waiting
}; // end saveDocument }; // end saveDocument
that.loadDocument = function (command) { that.loadDocument = function (command) {
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
'content': 'content', 'content': 'content',
'creation_date': 10000, 'creation_date': 10000,
'last_modified': 15000}; 'last_modified': 15000};
that.done(doc); that.success (doc);
}, 100); }, 100);
}; // end loadDocument }; // end loadDocument
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
delete list[0].content; delete list[0].content;
delete list[1].content; delete list[1].content;
} }
that.done(list); that.success (list);
}, 100); }, 100);
}; // end getDocumentList }; // end getDocumentList
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
// Remove a document from the storage. // Remove a document from the storage.
setTimeout (function () { setTimeout (function () {
that.done(); that.success ();
}, 100); }, 100);
}; };
return that; return that;
...@@ -72,45 +72,30 @@ ...@@ -72,45 +72,30 @@
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Dummy Storage 2 : all fail // Dummy Storage 2 : all fail
newDummyStorageAllFail = function ( spec, my ) { newDummyStorageAllFail = function ( spec, my ) {
var that = Jio.storage( spec, my, 'base' ); var that = Jio.storage( spec, my, 'base' ), priv = {};
that.setType('dummyallfail'); priv.error = function () {
setTimeout (function () {
that.error ({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
});
};
that.saveDocument = function (command) { that.saveDocument = function (command) {
// Tells us that the document is not saved. priv.error();
setTimeout (function () {
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
}; // end saveDocument }; // end saveDocument
that.loadDocument = function (command) { that.loadDocument = function (command) {
// Returns a document object containing nothing. priv.error();
setTimeout(function () {
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
}; // end loadDocument }; // end loadDocument
that.getDocumentList = function (command) { that.getDocumentList = function (command) {
// It returns nothing. priv.error();
setTimeout(function () {
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
}; // end getDocumentList }; // end getDocumentList
that.removeDocument = function (command) { that.removeDocument = function (command) {
// Remove a document from the storage. priv.error();
}; // end removeDocument
setTimeout (function () {
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
};
return that; return that;
}, },
// end Dummy Storage All Fail // end Dummy Storage All Fail
...@@ -121,13 +106,11 @@ ...@@ -121,13 +106,11 @@
newDummyStorageAllNotFound = function ( spec, my ) { newDummyStorageAllNotFound = function ( spec, my ) {
var that = Jio.storage( spec, my, 'base' ); var that = Jio.storage( spec, my, 'base' );
that.setType('dummyallnotfound');
that.saveDocument = function (command) { that.saveDocument = function (command) {
// Document does not exists yet, create it. // Document does not exists yet, create it.
setTimeout (function () { setTimeout (function () {
that.done(); that.success ();
}, 100); }, 100);
}; // end saveDocument }; // end saveDocument
...@@ -135,9 +118,9 @@ ...@@ -135,9 +118,9 @@
// Returns a document object containing nothing. // Returns a document object containing nothing.
setTimeout(function () { setTimeout(function () {
that.fail({status:404,statusText:'Not Found', that.error ({status:404,statusText:'Not Found',
message:'Document "'+ command.getPath() + message:'Document "'+ command.getPath() +
'" not found.'}); '" not found.'});
}, 100); }, 100);
}; // end loadDocument }; // end loadDocument
...@@ -145,8 +128,8 @@ ...@@ -145,8 +128,8 @@
// It returns nothing. // It returns nothing.
setTimeout(function () { setTimeout(function () {
that.fail({status:404,statusText:'Not Found', that.error ({status:404,statusText:'Not Found',
message:'User list not found.'}); message:'User list not found.'});
}, 100); }, 100);
}; // end getDocumentList }; // end getDocumentList
...@@ -154,7 +137,7 @@ ...@@ -154,7 +137,7 @@
// Remove a document from the storage. // Remove a document from the storage.
setTimeout (function () { setTimeout (function () {
that.done(); that.success ();
}, 100); }, 100);
}; };
return that; return that;
...@@ -167,8 +150,6 @@ ...@@ -167,8 +150,6 @@
newDummyStorageAll3Tries = function ( spec, my ) { newDummyStorageAll3Tries = function ( spec, my ) {
var that = Jio.storage( spec, my, 'base' ), priv = {}; var that = Jio.storage( spec, my, 'base' ), priv = {};
that.setType('dummyall3tries');
// this serialized method is used to make simple difference between // this serialized method is used to make simple difference between
// two dummyall3tries storages: // two dummyall3tries storages:
// so {type:'dummyall3tries',a:'b'} differs from // so {type:'dummyall3tries',a:'b'} differs from
...@@ -176,7 +157,7 @@ ...@@ -176,7 +157,7 @@
var super_serialized = that.serialized; var super_serialized = that.serialized;
that.serialized = function () { that.serialized = function () {
var o = super_serialized(); var o = super_serialized();
o.spec = spec; o.applicationname = spec.applicationname;
return o; return o;
}; };
...@@ -187,15 +168,20 @@ ...@@ -187,15 +168,20 @@
}, 100); }, 100);
}; };
priv.Try3OKElseFail = function (tries,if_ok_return) { priv.Try3OKElseFail = function (tries,if_ok_return) {
if ( tries === 3 ) { if ( typeof tries === 'undefined' ) {
return that.done(if_ok_return); return that.error ({status:0,statusText:'Unknown Error',
message:'Cannot get tried'});
} }
if ( tries < 3 ) { if ( tries < 3 ) {
return that.fail( return that.retry (
{message:'' + (3 - tries) + ' tries left.'}); {message:'' + (3 - tries) + ' tries left.'});
} }
if ( tries === 3 ) {
return that.success (if_ok_return);
}
if ( tries > 3 ) { if ( tries > 3 ) {
return that.fail({message:'Too much tries.'}); return that.error ({status:0,statusText:'Too Much Tries',
message:'Too much tries.'});
} }
}; };
......
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