Commit b0a00474 authored by Tristan Cavelier's avatar Tristan Cavelier

replicaterevisionstorage improve scenario test

parent 695b5ec7
...@@ -2321,216 +2321,216 @@ module ("JIO Replicate Revision Storage"); ...@@ -2321,216 +2321,216 @@ module ("JIO Replicate Revision Storage");
}, o.f); }, o.f);
o.tick(o); o.tick(o);
// // post a new document with id // post a new document with id
// o.doc = {"_id": "doc1", "title": "post new doc with id"}; o.doc = {"_id": "doc1", "title": "post new doc with id"};
// o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev}, o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
// "Post document (with id)"); "Post document (with id)");
// o.jio.post(o.doc, o.f); o.jio.post(o.doc, o.f);
// o.tick(o); o.tick(o);
// // / // // /
// // | // // |
// // 1-1 // // 1-1
// // check document // check document
// o.local_rev_hash = generateRevisionHash(o.doc, o.revision); o.local_rev_hash = generateRevisionHash(o.doc, o.revision);
// o.local_rev = "1-" + o.local_rev_hash; o.local_rev = "1-" + o.local_rev_hash;
// o.specific_rev_hash = o.local_rev_hash; o.specific_rev_hash = o.local_rev_hash;
// o.specific_rev = o.local_rev; o.specific_rev = o.local_rev;
// o.leavesAction(function (storage_description, param) { o.leavesAction(function (storage_description, param) {
// var suffix = "", doc = clone(o.doc); var suffix = "", doc = clone(o.doc);
// if (param.revision) { if (param.revision) {
// doc._id += "." + o.local_rev; doc._id += "." + o.local_rev;
// suffix = "." + o.local_rev; suffix = "." + o.local_rev;
// } }
// deepEqual( deepEqual(
// localstorage.getItem(generateLocalPath(storage_description) + localstorage.getItem(generateLocalPath(storage_description) +
// "/doc1" + suffix), "/doc1" + suffix),
// doc, "Check document" doc, "Check document"
// ); );
// }); });
// // get the post document without revision // get the post document without revision
// o.spy(o, "value", { o.spy(o, "value", {
// "_id": "doc1", "_id": "doc1",
// "title": "post new doc with id", "title": "post new doc with id",
// "_rev": "1-1", "_rev": "1-1",
// "_revisions": {"start": 1, "ids": ["1"]}, "_revisions": {"start": 1, "ids": ["1"]},
// "_revs_info": [{"rev": "1-1", "status": "available"}] "_revs_info": [{"rev": "1-1", "status": "available"}]
// }, "Get the previous document (without revision)"); }, "Get the previous document (without revision)");
// o.jio.get({"_id": "doc1"}, { o.jio.get({"_id": "doc1"}, {
// "conflicts": true, "conflicts": true,
// "revs": true, "revs": true,
// "revs_info": true "revs_info": true
// }, o.f); }, o.f);
// o.tick(o); o.tick(o);
// // post same document without revision
// o.doc = {"_id": "doc1", "title": "post same document without revision"};
// o.rev = "1-2";
// o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
// "Post same document (without revision)");
// o.jio.post(o.doc, o.f);
// o.tick(o);
// // / // post same document without revision
// // / \ o.doc = {"_id": "doc1", "title": "post same document without revision"};
// // 1-1 1-2 o.rev = "1-2";
o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
// // check document "Post same document (without revision)");
// o.local_rev = "1-" + generateRevisionHash(o.doc, o.revision); o.jio.post(o.doc, o.f);
// o.leavesAction(function (storage_description, param) { o.tick(o);
// var suffix = "", doc = clone(o.doc);
// if (param.revision) {
// doc._id += "." + o.local_rev;
// suffix = "." + o.local_rev;
// }
// deepEqual(
// localstorage.getItem(generateLocalPath(storage_description) +
// "/doc1" + suffix),
// doc, "Check document"
// );
// });
// // post a new revision // /
// o.doc = {"_id": "doc1", "title": "post new revision", "_rev": o.rev}; // / \
// o.rev = "2-3"; // 1-1 1-2
// o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
// "Post document (with revision)");
// o.jio.post(o.doc, o.f);
// o.tick(o);
// // / // check document
// // / \ o.local_rev = "1-" + generateRevisionHash(o.doc, o.revision);
// // 1-1 1-2 o.leavesAction(function (storage_description, param) {
// // | var suffix = "", doc = clone(o.doc);
// // 2-3 if (param.revision) {
doc._id += "." + o.local_rev;
// // check document suffix = "." + o.local_rev;
// o.revision.start += 1; }
// o.revision.ids.unshift(o.local_rev.split("-").slice(1).join("-")); deepEqual(
// o.doc._rev = o.local_rev; localstorage.getItem(generateLocalPath(storage_description) +
// o.local_rev = "2-" + generateRevisionHash(o.doc, o.revision); "/doc1" + suffix),
// o.specific_rev_conflict = o.local_rev; doc, "Check document"
// o.leavesAction(function (storage_description, param) { );
// var suffix = "", doc = clone(o.doc); });
// delete doc._rev;
// if (param.revision) {
// doc._id += "." + o.local_rev;
// suffix = "." + o.local_rev;
// }
// deepEqual(
// localstorage.getItem(generateLocalPath(storage_description) +
// "/doc1" + suffix),
// doc, "Check document"
// );
// });
// // get the post document with revision // post a new revision
// o.spy(o, "value", { o.doc = {"_id": "doc1", "title": "post new revision", "_rev": o.rev};
// "_id": "doc1", o.rev = "2-3";
// "title": "post same document without revision", o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
// "_rev": "1-2", "Post document (with revision)");
// "_revisions": {"start": 1, "ids": ["2"]}, o.jio.post(o.doc, o.f);
// "_revs_info": [{"rev": "1-2", "status": "available"}], o.tick(o);
// "_conflicts": ["1-1"]
// }, "Get the previous document (with revision)"); // /
// o.jio.get({"_id": "doc1", "_rev": "1-2"}, { // / \
// "conflicts": true, // 1-1 1-2
// "revs": true, // |
// "revs_info": true, // 2-3
// }, o.f);
// o.tick(o); // check document
o.revision.start += 1;
// // get the post document with specific revision o.revision.ids.unshift(o.local_rev.split("-").slice(1).join("-"));
// o.spy(o, "value", { o.doc._rev = o.local_rev;
// "_id": "doc1", o.local_rev = "2-" + generateRevisionHash(o.doc, o.revision);
// "title": "post new doc with id", o.specific_rev_conflict = o.local_rev;
// "_rev": o.specific_rev, o.leavesAction(function (storage_description, param) {
// "_revisions": {"start": 1, "ids": [o.specific_rev_hash]}, var suffix = "", doc = clone(o.doc);
// "_revs_info": [{"rev": o.specific_rev, "status": "available"}], delete doc._rev;
// "_conflicts": [o.specific_rev_conflict] if (param.revision) {
// }, "Get a previous document (with local storage revision)"); doc._id += "." + o.local_rev;
// o.jio.get({"_id": "doc1", "_rev": o.specific_rev}, { suffix = "." + o.local_rev;
// "conflicts": true, }
// "revs": true, deepEqual(
// "revs_info": true, localstorage.getItem(generateLocalPath(storage_description) +
// }, o.f); "/doc1" + suffix),
// o.tick(o); doc, "Check document"
);
// // put document without id });
// o.spy(o, "status", 20, "Put document without id")
// o.jio.put({}, o.f); // get the post document with revision
// o.tick(o); o.spy(o, "value", {
"_id": "doc1",
// // put document without rev "title": "post same document without revision",
// o.doc = {"_id": "doc1", "title": "put new document"}; "_rev": "1-2",
// o.rev = "1-4"; "_revisions": {"start": 1, "ids": ["2"]},
// o.spy(o, "value", {"id": "doc1", "ok": true, "rev": o.rev}, "_revs_info": [{"rev": "1-2", "status": "available"}],
// "Put document without rev") "_conflicts": ["1-1"]
// o.jio.put(o.doc, o.f); }, "Get the previous document (with revision)");
// o.tick(o); o.jio.get({"_id": "doc1", "_rev": "1-2"}, {
"conflicts": true,
// // __/__ "revs": true,
// // / | \ "revs_info": true
// // 1-1 1-2 1-4 }, o.f);
// // | o.tick(o);
// // 2-3
// get the post document with specific revision
// // put new revision o.spy(o, "value", {
// o.doc = {"_id": "doc1", "title": "put new revision", "_rev": "1-4"}; "_id": "doc1",
// o.rev = "2-5"; "title": "post new doc with id",
// o.spy(o, "value", {"id": "doc1", "ok": true, "rev": o.rev}, "_rev": o.specific_rev,
// "Put document without rev") "_revisions": {"start": 1, "ids": [o.specific_rev_hash]},
// o.jio.put(o.doc, o.f); "_revs_info": [{"rev": o.specific_rev, "status": "available"}],
// o.tick(o); "_conflicts": [o.specific_rev_conflict]
}, "Get a previous document (with local storage revision)");
// // __/__ o.jio.get({"_id": "doc1", "_rev": o.specific_rev}, {
// // / | \ "conflicts": true,
// // 1-1 1-2 1-4 "revs": true,
// // | | "revs_info": true
// // 2-3 2-5 }, o.f);
o.tick(o);
// // putAttachment to inexistent document
// // putAttachment // put document without id
// // get document o.spy(o, "status", 20, "Put document without id")
// // get attachment o.jio.put({}, o.f);
// // put document o.tick(o);
// // get document
// // get attachment // put document without rev
// // remove attachment o.doc = {"_id": "doc1", "title": "put new document"};
// // get document o.rev = "1-4";
// // get inexistent attachment o.spy(o, "value", {"id": "doc1", "ok": true, "rev": o.rev},
"Put document without rev")
// // remove document and conflict o.jio.put(o.doc, o.f);
// o.rev = "3-6"; o.tick(o);
// o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
// "Remove document"); // __/__
// o.jio.remove({"_id": "doc1", "_rev": "2-5"}, o.f); // / | \
// o.tick(o); // 1-1 1-2 1-4
// |
// // remove document and conflict // 2-3
// o.rev = "3-7";
// o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev}, // put new revision
// "Remove document"); o.doc = {"_id": "doc1", "title": "put new revision", "_rev": "1-4"};
// o.jio.remove({"_id": "doc1", "_rev": "2-3"}, o.f); o.rev = "2-5";
// o.tick(o); o.spy(o, "value", {"id": "doc1", "ok": true, "rev": o.rev},
"Put document without rev")
// // remove document o.jio.put(o.doc, o.f);
// o.rev = "2-8"; o.tick(o);
// o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
// "Remove document"); // __/__
// o.jio.remove({"_id": "doc1", "_rev": "1-1"}, o.f); // / | \
// o.tick(o); // 1-1 1-2 1-4
// | |
// // get inexistent document // 2-3 2-5
// o.spy(o, "status", 404, "Get inexistent document");
// o.jio.get({"_id": "doc1"}, { // putAttachment to inexistent document
// "conflicts": true, // putAttachment
// "revs": true, // get document
// "revs_info": true // get attachment
// }, o.f); // put document
// o.tick(o); // get document
// get attachment
// remove attachment
// get document
// get inexistent attachment
// remove document and conflict
o.rev = "3-6";
o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
"Remove document");
o.jio.remove({"_id": "doc1", "_rev": "2-5"}, o.f);
o.tick(o);
// remove document and conflict
o.rev = "3-7";
o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
"Remove document");
o.jio.remove({"_id": "doc1", "_rev": "2-3"}, o.f);
o.tick(o);
// remove document
o.rev = "2-8";
o.spy(o, "value", {"ok": true, "id": "doc1", "rev": o.rev},
"Remove document");
o.jio.remove({"_id": "doc1", "_rev": "1-1"}, o.f);
o.tick(o);
// get inexistent document
o.spy(o, "status", 404, "Get inexistent document");
o.jio.get({"_id": "doc1"}, {
"conflicts": true,
"revs": true,
"revs_info": true
}, o.f);
o.tick(o);
o.jio.stop(); o.jio.stop();
......
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