Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
jio
Commits
90d37ed6
Commit
90d37ed6
authored
Dec 20, 2012
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PUTATTACHEMENT working, removed methods to util
parent
eca94a2a
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
471 additions
and
337 deletions
+471
-337
src/jio.storage/intro.js
src/jio.storage/intro.js
+82
-48
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+266
-260
src/jio/commands/command.js
src/jio/commands/command.js
+2
-0
test/jiotests.js
test/jiotests.js
+121
-29
No files found.
src/jio.storage/intro.js
View file @
90d37ed6
This diff is collapsed.
Click to expand it.
src/jio.storage/localstorage.js
View file @
90d37ed6
This diff is collapsed.
Click to expand it.
src/jio/commands/command.js
View file @
90d37ed6
...
...
@@ -80,6 +80,8 @@ var command = function(spec, my) {
* @return {object} the document.
*/
that
.
getDoc
=
function
()
{
console
.
log
(
"
where is my doc
"
);
console
.
log
(
priv
.
doc
);
return
priv
.
doc
;
};
...
...
test/jiotests.js
View file @
90d37ed6
...
...
@@ -359,10 +359,12 @@ test ('All tests', function () {
_creation_date:10000},'dummyallok loading');
o.jio.get('file',o.f);
o.tick(o);
// remove
o.spy(o,'value',{ok:true,id:"file"},'dummyallok removing');
o.jio.remove({_id:'file'},o.f);
o.tick(o);
// get list
o.spy (o,'value',{
total_rows:2,
...
...
@@ -728,23 +730,35 @@ test ('Put', function(){
// runs following assertions
// 1) PUT without ID = 409
// 2) PUT with wrong ID/rev = 404
// 3)
PUT CREATE
// 3)
PUT CREATE response
// 4) check file was created
// 5) check tree was created
// 6)
PUT UPDATE
// 6)
PUT UPDATE response
// 7) check file was replaced
// 8) check tree was updated
// 9)
PUT UPDATE 2
// 9)
PUT UPDATE 2 response
// 10) check file was replaced
// 11) check tree was updated
// 12) PUT UPDATE false revision = 409
// 13) SYNC-PUT no revs_info = 409
// 14) SYNC-PUT revs_info
// 14) SYNC-PUT revs_info response
// 15) check if file created
// 16) check if tree was merged
// 17) SYNC-PUT revs_info dead leaf response
// 18) check that file was NOT created
// 19) check that tree was updated
var
fake_rev_0
,
fake_rev_1
,
fake_rev_2
,
fake_id_0
,
fake_id_1
,
fake_id_2
,
var
o
=
{};
o
=
{};
o
.
t
=
this
;
o
.
clock
=
o
.
t
.
sandbox
.
useFakeTimers
()
,
o
.
falseRevision
,
o
.
clock
=
o
.
t
.
sandbox
.
useFakeTimers
()
;
o
.
falseRevision
;
localstorage
=
{
getItem
:
function
(
item
)
{
return
JSON
.
parse
(
localStorage
.
getItem
(
item
));
...
...
@@ -791,6 +805,8 @@ test ('Put', function(){
"
_rev
"
:
'
1-ABCDEFG
'
},
o
.
f
);
checkReply
(
o
,
null
,
true
);
o
.
clock
.
tick
(
base_tick
);
// start adding content
o
.
jio
.
put
({
"
content
"
:
'
content
'
,
"
_id
"
:
'
myDoc
'
},
function
(
err
,
response
)
{
...
...
@@ -813,9 +829,10 @@ test ('Put', function(){
});
// 3) TEST PUT content
// no idea why this is working for 3/6/9/12, but it does...
checkReply
(
o
,
null
,
true
);
o
.
clock
.
tick
(
base_tick
);
// update document
o
.
jio
.
put
({
"
content
"
:
'
content_modified
'
,
"
_id
"
:
'
myDoc
'
,
"
_rev
"
:
o
.
testRevisionStorage
[
0
]},
...
...
@@ -839,12 +856,13 @@ test ('Put', function(){
// 6) TEST PUT UPDATE
checkReply
(
o
,
null
,
true
);
o
.
clock
.
tick
(
base_tick
);
// update document 2nd time
o
.
jio
.
put
({
"
content
"
:
'
content_modified_again
'
,
"
_id
"
:
'
myDoc
'
,
"
_rev
"
:
o
.
testRevisionStorage
[
0
]},
function
(
err
,
response
)
{
var
fake_rev_0
,
fake_rev_1
,
fake_id_0
,
fake_id_1
;
o
.
spy
(
o
,
'
value
'
,{
"
ok
"
:
true
,
"
id
"
:
response
.
id
,
"
rev
"
:
response
.
rev
},
'
PUT content = ok
'
);
...
...
@@ -867,11 +885,9 @@ test ('Put', function(){
// 9) TEST PUT UPDATE
checkReply
(
o
,
null
,
true
);
// continue to work with this instance
//o.jio.stop();
//o.clean;
o
.
clock
.
tick
(
base_tick
);
//
try updating with
false revision
//
TEST 12) PUT
false revision
o
.
spy
(
o
,
'
value
'
,{
"
error
"
:
'
conflict
'
,
"
message
"
:
'
Document update conflict.
'
,
...
...
@@ -884,11 +900,11 @@ test ('Put', function(){
o
.
jio
.
put
({
"
content
"
:
'
content_modified_false
'
,
"
_id
"
:
'
myDoc
'
,
"
_rev
"
:
o
.
falseRevision
},
o
.
f
);
// TEST 12) PUT false revision
checkReply
(
o
,
null
,
true
);
o
.
clock
.
tick
(
base_tick
);
//
try updating without
revs_info
//
TEST 13) SYNC-PUT no
revs_info
o
.
spy
(
o
,
'
value
'
,{
"
error
"
:
'
conflict
'
,
"
message
"
:
'
Document update conflict.
'
,
...
...
@@ -901,9 +917,10 @@ test ('Put', function(){
o
.
jio
.
put
({
"
content
"
:
'
content_modified_false
'
,
"
_id
"
:
'
myDoc
'
,
"
_rev
"
:
'
1-abcdefg
'
},
o
.
f
);
// TEST 13) SYNC-PUT no revs_info
checkReply
(
o
,
null
,
true
);
o
.
clock
.
tick
(
base_tick
);
// add a new document version with fake revs_info
// the new document has the same origin and first edit,
// then it was changed to a new version (3-a9d...),
...
...
@@ -912,10 +929,12 @@ test ('Put', function(){
// and add the two new dummy revisions into the final
// tree. Also the new document should be stored
// in local storage.
fake_rev_2
=
o
.
testRevisionStorage
[
2
];
fake_rev_1
=
o
.
testRevisionStorage
[
1
];
fake_rev_0
=
o
.
testRevisionStorage
[
0
];
fake_id_
0
=
o
.
testRevisionStorage
[
0
].
split
(
'
-
'
)[
1
];
fake_id_
2
=
o
.
testRevisionStorage
[
2
].
split
(
'
-
'
)[
1
];
fake_id_1
=
o
.
testRevisionStorage
[
1
].
split
(
'
-
'
)[
1
];
fake_id_0
=
o
.
testRevisionStorage
[
0
].
split
(
'
-
'
)[
1
];
// put a new document version
o
.
jio
.
put
({
...
...
@@ -970,7 +989,80 @@ test ('Put', function(){
// 14) TEST PUT UPDATE
checkReply
(
o
,
null
,
true
);
o
.
clock
.
tick
(
base_tick
);
/*
// put a new deleted version
o.jio.put({
"content":'a_deleted_version',
"_id":'myDoc',
"_rev":"3-05210795b6aa8cb5e1e7f021960d233cf963f1052b1a41777ca1a2aff8fd4b61",
"_revs_info":[
{"rev":"3-05210795b6aa8cb5e1e7f021960d233cf963f1052b1a41777ca1a2aff8fd4b61","status":"deleted"},
{"rev":"2-67ac10df5b7e2582f2ea2344b01c68d461f44b98fef2c5cba5073cc3bdb5a844","status":"deleted"},
{"rev":fake_rev_2,"status":"deleted"}
],
"_revisions":{
"start":3,
"ids":[
"05210795b6aa8cb5e1e7f021960d233cf963f1052b1a41777ca1a2aff8fd4b61",
"67ac10df5b7e2582f2ea2344b01c68d461f44b98fef2c5cba5073cc3bdb5a844",
fake_id_2
]}
},
function(err, response) {
//o.testRevisionStorage.unshift(response.rev);
o.buildTestTree = {
"kids":[{
"kids":[
{"kids":[],
"rev":o.testRevisionStorage[0],
"status":'available',
"type":'leaf'
},
{"kids":[{
"kids":[],
"rev":"4-b5bb2f1657ac5ac270c14b2335e51ef1ffccc0a7259e14bce46380d6c446eb89",
"status":'available', "type":'leaf'
}],
"rev":"3-a9dac9ff5c8e1b2fce58e5397e9b6a8de729d5c6eff8f26a7b71df6348986123",
"status":'deleted',
"type":'branch'
}],
"rev":o.testRevisionStorage[1],
"status":'deleted',
"type":'branch'
},{
"kids":[
{
"kids":[],
"rev":"3-05210795b6aa8cb5e1e7f021960d233cf963f1052b1a41777ca1a2aff8fd4b61",
"status":'deleted',
"type":'leaf'
}],
"rev":"2-67ac10df5b7e2582f2ea2344b01c68d461f44b98fef2c5cba5073cc3bdb5a844",
"status":'deleted',
"typ":'branch'
}],
"rev":o.testRevisionStorage[2],
"status":'deleted',
"type":'branch'
};
o.spy(o,'value',{"ok":true,"id":response.id,
"rev":response.rev}, 'PUT SYNC dead leaf = ok');
o.f(response);
// TEST 18) check document was stored
//checkFile(response, o, null, true);
// TEST 19) check tree was updated
//checkTreeNode(response, o, null, true);
});
// 17) TEST PUT UPDATE
//checkReply(o,null,true);
*/
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment