Commit 22e0d7cd authored by Tristan Cavelier's avatar Tristan Cavelier

Improve Jiotests

parent f6b9189a
...@@ -1148,7 +1148,7 @@ test ('Simple methods', function () { ...@@ -1148,7 +1148,7 @@ test ('Simple methods', function () {
}; };
o.t.spy(o,'f'); o.t.spy(o,'f');
}; };
o.tick = function (value, tick) { o.tick = function (tick) {
o.clock.tick(tick || 1000); o.clock.tick(tick || 1000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
if (o.f.called) { if (o.f.called) {
...@@ -1165,7 +1165,7 @@ test ('Simple methods', function () { ...@@ -1165,7 +1165,7 @@ test ('Simple methods', function () {
applicationname:'jiotests'}}); applicationname:'jiotests'}});
o.spy('status','done','saving "file.doc" with owner "methods".'); o.spy('status','done','saving "file.doc" with owner "methods".');
o.jio.saveDocument('file.doc','content1methods', o.jio.saveDocument('file.doc','content1methods',
{onResponse:o.f,max_retry:1}); {onResponse:o.f});
o.tick(); o.tick();
o.spy('value',{name:'file.doc',content:'content1methods'}, o.spy('value',{name:'file.doc',content:'content1methods'},
...@@ -1362,13 +1362,14 @@ test ('Revision Conflicts' , function () { ...@@ -1362,13 +1362,14 @@ test ('Revision Conflicts' , function () {
{onResponse:o.f,max_retry:1}); {onResponse:o.f,max_retry:1});
o.tick(); o.tick();
// me tries to save his new revision o.conflict_callback = function (conflict_object) {
o.spy('status','fail','saving "file.doc" with owner "me",'+
' third revision, conflict!');
o.c = function (conflict_object) {
o.conflict_object = conflict_object; o.conflict_object = conflict_object;
ok (true,'onConflict callback called once'); ok (true,'onConflict callback called once');
}; };
// me tries to save his new revision
o.spy('status','fail','saving "file.doc" with owner "me",'+
' third revision, conflict!');
o.c = o.conflict_callback;
o.t.spy(o,'c'); o.t.spy(o,'c');
o.jio_me.saveDocument('file.doc','content3me',{ o.jio_me.saveDocument('file.doc','content3me',{
onResponse:o.f,max_retry:1,onConflict:o.c}); onResponse:o.f,max_retry:1,onConflict:o.c});
...@@ -1380,10 +1381,7 @@ test ('Revision Conflicts' , function () { ...@@ -1380,10 +1381,7 @@ test ('Revision Conflicts' , function () {
// me tries to save again but does not solve anything // me tries to save again but does not solve anything
o.spy('status','fail',"don't solve anything,"+ o.spy('status','fail',"don't solve anything,"+
' save "file.doc" with owner "me", forth revision, conflict!'); ' save "file.doc" with owner "me", forth revision, conflict!');
o.c = function (conflict_object) { o.c = o.conflict_callback;
o.conflict_object = conflict_object;
ok (true,'onConflict callback called once');
};
o.t.spy(o,'c'); o.t.spy(o,'c');
o.jio_me.saveDocument('file.doc','content4me',{ o.jio_me.saveDocument('file.doc','content4me',{
onResponse:o.f,max_retry:1,onConflict:o.c}); onResponse:o.f,max_retry:1,onConflict:o.c});
...@@ -1391,6 +1389,10 @@ test ('Revision Conflicts' , function () { ...@@ -1391,6 +1389,10 @@ test ('Revision Conflicts' , function () {
o.tick(0,'c'); o.tick(0,'c');
if(!o.conflict_object){return ok(false,'impossible to continue the tests');} if(!o.conflict_object){return ok(false,'impossible to continue the tests');}
o.spy('status','done','get a document list');
o.jio_me.getDocumentList('.',{onResponse:o.f,max_retry:1});
o.tick();
// me saves the revision created by solving the conflict // me saves the revision created by solving the conflict
o.spy('status','done','solving conflict and save "file.doc" with owner'+ o.spy('status','done','solving conflict and save "file.doc" with owner'+
' "me", forth revision, no conflict.'); ' "me", forth revision, no conflict.');
...@@ -1410,10 +1412,7 @@ test ('Revision Conflicts' , function () { ...@@ -1410,10 +1412,7 @@ test ('Revision Conflicts' , function () {
// him tries to save a new revision but the document does not exist anymore // him tries to save a new revision but the document does not exist anymore
o.spy('status','fail','saving "file.doc" with owner "him",'+ o.spy('status','fail','saving "file.doc" with owner "him",'+
' any revision, conflict!'); ' any revision, conflict!');
o.c = function (conflict_object) { o.c = o.conflict_callback;
o.conflict_object = conflict_object;
ok (true,'onConflict callback called once');
};
o.t.spy(o,'c'); o.t.spy(o,'c');
o.jio_him.saveDocument('file.doc','content4him',{ o.jio_him.saveDocument('file.doc','content4him',{
onResponse:o.f,max_retry:1,onConflict:o.c}); onResponse:o.f,max_retry:1,onConflict:o.c});
...@@ -1457,6 +1456,10 @@ test ('Solving Conflict Conflicts' , function () { ...@@ -1457,6 +1456,10 @@ test ('Solving Conflict Conflicts' , function () {
} }
} }
}; };
o.conflict_callback = function (conflict_object) {
o.conflict_object = conflict_object;
ok (true,'onConflict callback called once');
};
o.jio_you = JIO.newJio({type:'conflictmanager', o.jio_you = JIO.newJio({type:'conflictmanager',
username:'you', username:'you',
storage:{type:'local', storage:{type:'local',
...@@ -1487,10 +1490,7 @@ test ('Solving Conflict Conflicts' , function () { ...@@ -1487,10 +1490,7 @@ test ('Solving Conflict Conflicts' , function () {
o.spy('status','fail','saving "file.doc" with owner "you",'+ o.spy('status','fail','saving "file.doc" with owner "you",'+
' second revision, conflict!'); ' second revision, conflict!');
o.c = function (conflict_object) { o.c = o.conflict_callback;
o.conflict_object = conflict_object;
ok (true,'onConflict callback called once');
};
o.t.spy(o,'c'); o.t.spy(o,'c');
o.jio_you.saveDocument('file.doc','content3you',{ o.jio_you.saveDocument('file.doc','content3you',{
onResponse:o.f,max_retry:1,onConflict:o.c}); onResponse:o.f,max_retry:1,onConflict:o.c});
...@@ -1506,10 +1506,7 @@ test ('Solving Conflict Conflicts' , function () { ...@@ -1506,10 +1506,7 @@ test ('Solving Conflict Conflicts' , function () {
o.spy('status','fail','solving conflict and save "file.doc" with owner'+ o.spy('status','fail','solving conflict and save "file.doc" with owner'+
' "you", fith revision, conflict!'); ' "you", fith revision, conflict!');
o.c = function (conflict_object) { o.c = o.conflict_callback;
o.conflict_object = conflict_object;
ok (true, 'onConflict callback called once');
};
o.t.spy(o,'c'); o.t.spy(o,'c');
o.jio_you.saveDocument('file.doc','content4you',{ o.jio_you.saveDocument('file.doc','content4you',{
onResponse:o.f,max_retry:1,known_conflict_list:[o.conflict_object], onResponse:o.f,max_retry:1,known_conflict_list:[o.conflict_object],
......
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