Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Stefane Fermigier
jio
Commits
e1821253
Commit
e1821253
authored
Jan 07, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qunit test scenario revision and local storage
parent
2b6d19ea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
19 deletions
+46
-19
test/jiotests.js
test/jiotests.js
+46
-19
No files found.
test/jiotests.js
View file @
e1821253
...
@@ -1508,9 +1508,9 @@ test ("Remove", function(){
...
@@ -1508,9 +1508,9 @@ test ("Remove", function(){
});
});
module
(
"
Test Revisionstorage + Locals
torage
"
);
module
(
"
Jio Revision Storage + Local S
torage
"
);
test
(
"
sample
"
,
function
(){
test
(
"
Scenario
"
,
function
(){
var
o
=
generateTools
(
this
);
var
o
=
generateTools
(
this
);
...
@@ -1527,7 +1527,8 @@ test ("sample", function(){
...
@@ -1527,7 +1527,8 @@ test ("sample", function(){
// 1. put non empty document A-1
// 1. put non empty document A-1
o
.
doc
=
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample1
"
};
o
.
doc
=
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample1
"
};
o
.
revs_info
=
[];
o
.
revs_info
=
[];
o
.
rev
=
"
1-
"
+
hex_sha256
(
JSON
.
stringify
(
o
.
doc
)
+
JSON
.
stringify
(
o
.
revs_info
));
o
.
hex
=
hex_sha256
(
JSON
.
stringify
(
o
.
doc
)
+
JSON
.
stringify
(
o
.
revs_info
));
o
.
rev
=
"
1-
"
+
o
.
hex
;
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
sample1
"
,
"
rev
"
:
o
.
rev
},
"
Put non empty document A-1
"
);
o
.
spy
(
o
,
"
value
"
,
{
"
ok
"
:
true
,
"
id
"
:
"
sample1
"
,
"
rev
"
:
o
.
rev
},
"
Put non empty document A-1
"
);
o
.
jio
.
put
(
o
.
doc
,
o
.
f
);
o
.
jio
.
put
(
o
.
doc
,
o
.
f
);
...
@@ -1545,7 +1546,8 @@ test ("sample", function(){
...
@@ -1545,7 +1546,8 @@ test ("sample", function(){
// 3. FAKE IT
// 3. FAKE IT
o
.
doc_f
=
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample2
"
};
o
.
doc_f
=
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample2
"
};
o
.
revs_info_f
=
[];
o
.
revs_info_f
=
[];
o
.
rev_f
=
"
1-
"
+
hex_sha256
(
JSON
.
stringify
(
o
.
doc_f
)
+
JSON
.
stringify
(
o
.
revs_info_f
));
o
.
hex_f
=
hex_sha256
(
JSON
.
stringify
(
o
.
doc_f
)
+
JSON
.
stringify
(
o
.
revs_info_f
));
o
.
rev_f
=
"
1-
"
+
o
.
hex_f
;
o
.
doc_f2
=
{
"
_id
"
:
"
sample1.
"
+
o
.
rev_f
,
"
title
"
:
"
mySample2
"
};
o
.
doc_f2
=
{
"
_id
"
:
"
sample1.
"
+
o
.
rev_f
,
"
title
"
:
"
mySample2
"
};
localstorage
.
setItem
(
o
.
localpath
+
"
/sample1.
"
+
o
.
rev_f
,
o
.
doc_f2
);
localstorage
.
setItem
(
o
.
localpath
+
"
/sample1.
"
+
o
.
rev_f
,
o
.
doc_f2
);
...
@@ -1557,40 +1559,65 @@ test ("sample", function(){
...
@@ -1557,40 +1559,65 @@ test ("sample", function(){
localstorage
.
setItem
(
o
.
localpath
+
"
/sample1.revision_tree.json
"
,
o
.
doctree
);
localstorage
.
setItem
(
o
.
localpath
+
"
/sample1.revision_tree.json
"
,
o
.
doctree
);
// 3. GET first version
// 3. GET first version
o
.
spy
(
o
,
"
value
"
,
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample1
"
,
"
_rev
"
:
o
.
rev
},
o
.
mydocSample1
=
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample1
"
,
"
_rev
"
:
o
.
rev
};
"
Get first document (using revison)
"
);
o
.
mydocSample1
.
_revisions
=
{
"
ids
"
:[
o
.
hex
],
"
start
"
:
1
};
o
.
jio
.
get
(
"
sample1
"
,
{
"
rev
"
:
o
.
rev
},
o
.
f
);
o
.
mydocSample1
.
_revs_info
=
[{
"
rev
"
:
o
.
rev
,
"
status
"
:
"
available
"
}];
o
.
mydocSample1
.
_conflicts
=
[
o
.
rev_f
];
o
.
spy
(
o
,
"
value
"
,
o
.
mydocSample1
,
"
Get first document (using revison)
"
);
o
.
jio
.
get
(
"
sample1
"
,
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
o
.
rev
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
// 4. MODFIY first version
// 4. MODFIY first version
o
.
doc_2
=
{
"
_id
"
:
"
sample1
"
,
"
_rev
"
:
o
.
rev
,
"
title
"
:
"
mySample1_modified
"
};
o
.
doc_2
=
{
"
_id
"
:
"
sample1
"
,
"
_rev
"
:
o
.
rev
,
"
title
"
:
"
mySample1_modified
"
};
o
.
revs_info_2
=
[{
"
rev
"
:
o
.
rev
,
"
status
"
:
"
available
"
}];
o
.
revs_info_2
=
o
.
mydocSample1
.
_revs_info
;
o
.
rev_2
=
"
2-
"
+
hex_sha256
(
JSON
.
stringify
(
o
.
doc_2
)
+
JSON
.
stringify
(
o
.
revs_info_2
));
o
.
hex_2
=
hex_sha256
(
JSON
.
stringify
(
o
.
doc_2
)
+
JSON
.
stringify
(
o
.
revs_info_2
));
o
.
rev_2
=
"
2-
"
+
o
.
hex_2
;
o
.
spy
(
o
,
"
value
"
,
{
"
id
"
:
"
sample1
"
,
"
ok
"
:
true
,
"
rev
"
:
o
.
rev_2
},
"
Modify first document
"
);
o
.
spy
(
o
,
"
value
"
,
{
"
id
"
:
"
sample1
"
,
"
ok
"
:
true
,
"
rev
"
:
o
.
rev_2
},
"
Modify first document
"
);
o
.
jio
.
put
(
o
.
doc_2
,
o
.
f
);
o
.
jio
.
put
(
o
.
doc_2
,
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
// 5. GET second version
// 5. GET second version
o
.
spy
(
o
,
"
value
"
,
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample2
"
,
"
_rev
"
:
o
.
rev_f
},
o
.
mydocSample2
=
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample2
"
,
"
_rev
"
:
o
.
rev_f
};
o
.
mydocSample2
.
_revisions
=
{
"
ids
"
:[
o
.
hex_f
],
"
start
"
:
1
};
o
.
mydocSample2
.
_revs_info
=
[{
"
rev
"
:
o
.
rev_f
,
"
status
"
:
"
available
"
}];
o
.
mydocSample2
.
_conflicts
=
[
o
.
rev_2
];
o
.
spy
(
o
,
"
value
"
,
o
.
mydocSample2
,
"
Get second document (using revison)
"
);
"
Get second document (using revison)
"
);
o
.
jio
.
get
(
"
sample1
"
,
{
"
rev
"
:
o
.
rev_f
},
o
.
f
);
o
.
jio
.
get
(
"
sample1
"
,
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
"
rev
"
:
o
.
rev_f
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
// 6. MODFIY second version
// 6. MODFIY second version
o
.
doc_f2
=
{
"
_id
"
:
"
sample1
"
,
"
_rev
"
:
o
.
rev_f
,
"
title
"
:
"
mySample2_modified
"
};
o
.
doc_f2
=
{
"
_id
"
:
"
sample1
"
,
"
_rev
"
:
o
.
rev_f
,
o
.
revs_info_f2
=
[{
"
rev
"
:
o
.
rev_f
,
"
status
"
:
"
available
"
}];
"
title
"
:
"
mySample2_modified
"
};
o
.
rev_f2
=
"
2-
"
+
hex_sha256
(
JSON
.
stringify
(
o
.
doc_f2
)
+
JSON
.
stringify
(
o
.
revs_info_f2
));
o
.
revs_info_f2
=
o
.
mydocSample2
.
_revs_info
;
o
.
spy
(
o
,
"
value
"
,
{
"
id
"
:
"
sample1
"
,
"
ok
"
:
true
,
"
rev
"
:
o
.
rev_f2
},
"
Modify second document
"
);
o
.
hex_f2
=
hex_sha256
(
JSON
.
stringify
(
o
.
doc_f2
)
+
JSON
.
stringify
(
o
.
revs_info_f2
));
o
.
rev_f2
=
"
2-
"
+
o
.
hex_f2
;
o
.
spy
(
o
,
"
value
"
,
{
"
id
"
:
"
sample1
"
,
"
ok
"
:
true
,
"
rev
"
:
o
.
rev_f2
},
"
Modify second document
"
);
o
.
jio
.
put
(
o
.
doc_f2
,
o
.
f
);
o
.
jio
.
put
(
o
.
doc_f2
,
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
// 7. GET document with conflict!
// 7. GET document without revision = winner & conflict!
o
.
spy
(
o
,
"
value
"
,
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample2
"
,
"
_rev
"
:
o
.
rev_f
},
o
.
mydocSample3
=
{
"
_id
"
:
"
sample1
"
,
"
title
"
:
"
mySample1_modified
"
,
"
Get second document (using revison)
"
);
"
_rev
"
:
o
.
rev_2
,
"
_conflicts
"
:[
o
.
rev_f2
]};
o
.
jio
.
get
(
"
sample1
"
,
o
.
f
);
o
.
mydocSample3
.
_revs_info
=
[{
"
rev
"
:
o
.
rev_2
,
"
status
"
:
"
available
"
},{
"
rev
"
:
o
.
rev
,
"
status
"
:
"
available
"
}];
o
.
mydocSample3
.
_revisions
=
{
"
ids
"
:[
o
.
hex_2
,
o
.
hex
],
"
start
"
:
2
};
o
.
spy
(
o
,
"
value
"
,
o
.
mydocSample3
,
"
Get second document (using revison) = Two conflicting versions
"
);
o
.
jio
.
get
(
"
sample1
"
,
{
"
revs_info
"
:
true
,
"
revs
"
:
true
,
"
conflicts
"
:
true
,
},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
/*
/*
module ('Jio DAVStorage');
module ('Jio DAVStorage');
...
...
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