Commit 7f5f4e44 authored by Tristan Cavelier's avatar Tristan Cavelier

gidstorage added + tests (wip)

parent a68b440b
...@@ -164,6 +164,8 @@ var clearlog = function () { ...@@ -164,6 +164,8 @@ var clearlog = function () {
</script> </script>
<script type="text/javascript" src="../src/jio.storage/splitstorage.js"> <script type="text/javascript" src="../src/jio.storage/splitstorage.js">
</script> </script>
<script type="text/javascript" src="../src/jio.storage/gidstorage.js">
</script>
<script type="text/javascript" src="../lib/sjcl/sjcl.min.js"></script> <script type="text/javascript" src="../lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
......
This diff is collapsed.
...@@ -7963,6 +7963,97 @@ test("AllDocs", function () { ...@@ -7963,6 +7963,97 @@ test("AllDocs", function () {
o.jio.stop(); o.jio.stop();
}); });
module("JIO GID Storage");
test("Post", function () {
var o = generateTools(this);
o.localstorage_spec = {
"type": "local",
"username": "one",
"application_name": "gid storage post test"
};
o.local_jio = JIO.newJio(o.localstorage_spec);
o.jio = JIO.newJio({
"type": "gid",
"sub_storage": o.localstorage_spec,
"constraints": {
"default": {
"identifier": "list"
}
}
});
o.local_jio.put({"_id": "blue", "identifier": "a"});
o.local_jio.put({"_id": "green", "identifier": ["ac", "b"]});
o.clock.tick(2000);
o.local_jio.stop();
o.spy(o, 'status', 409, 'Post document without respecting constraints ' +
'-> conflicts');
o.jio.post({}, o.f);
o.tick(o);
o.spy(o, 'status', 409, 'Post existent document -> conflict');
o.jio.post({"identifier": "a"}, o.f);
o.tick(o);
o.spy(o, 'value', {
"id": "{\"identifier\":[\"a%\"]}",
"ok": true
}, 'Post respecting constraints');
o.jio.post({"identifier": "a%"}, o.f);
o.tick(o);
o.spy(o, 'status', 409, 'Post same document respecting constraints ' +
'-> conflicts');
o.jio.post({"identifier": "a%"}, o.f);
o.tick(o);
o.jio.stop();
});
test("Get", function () {
var o = generateTools(this);
o.localstorage_spec = {
"type": "local",
"username": "one",
"application_name": "gid storage get test"
};
o.local_jio = JIO.newJio(o.localstorage_spec);
o.jio = JIO.newJio({
"type": "gid",
"sub_storage": o.localstorage_spec,
"constraints": {
"default": {
"identifier": "list"
}
}
});
o.local_jio.put({"_id": "blue", "identifier": "a"});
o.local_jio.put({"_id": "green", "identifier": ["ac", "b"]});
o.clock.tick(2000);
o.local_jio.stop();
o.spy(o, 'status', 404, 'Get inexistent document');
o.jio.get({"_id": "{\"identifier\":[\"b\"]}"}, o.f);
o.tick(o);
o.spy(o, 'value', {"_id": "blue", "identifier": "a"}, 'Get document');
o.jio.get({"_id": "{\"identifier\":[\"a\"]}"}, o.f);
o.tick(o);
o.jio.stop();
});
}; // end thisfun }; // end thisfun
if (window.requirejs) { if (window.requirejs) {
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
</script> </script>
<script type="text/javascript" src="../src/jio.storage/splitstorage.js"> <script type="text/javascript" src="../src/jio.storage/splitstorage.js">
</script> </script>
<script type="text/javascript" src="../src/jio.storage/gidstorage.js">
</script>
<script type="text/javascript" src="./jiotests.js"></script> <script type="text/javascript" src="./jiotests.js"></script>
</body> </body>
</html> </html>
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