Commit 87f4360e authored by Bryan Kaperick's avatar Bryan Kaperick

Added additional allDocs test.

parent 6f1464b1
...@@ -702,22 +702,22 @@ ...@@ -702,22 +702,22 @@
test("Putting a document, revising it, and retrieving revisions with allDocs", test("Putting a document, revising it, and retrieving revisions with allDocs",
function () { function () {
stop(); stop();
expect(13); expect(14);
var context = this, var jio = this.jio,
timestamps; not_history = this.not_history,
context.jio.put("doc", { timestamps = this.jio.__storage._timestamps;
jio.put("doc", {
title: "version0", title: "version0",
subtitle: "subvers0" subtitle: "subvers0"
}) })
.push(function () { .push(function () {
return context.jio.put("doc", { return jio.put("doc", {
title: "version1", title: "version1",
subtitle: "subvers1" subtitle: "subvers1"
}); });
}) })
.push(function () { .push(function () {
timestamps = context.jio.__storage._timestamps.doc; return jio.put("doc", {
return context.jio.put("doc", {
title: "version2", title: "version2",
subtitle: "subvers2" subtitle: "subvers2"
}); });
...@@ -725,24 +725,24 @@ ...@@ -725,24 +725,24 @@
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
context.jio.allDocs({select_list: ["title", "subtitle"]}), jio.allDocs({select_list: ["title", "subtitle"]}),
context.jio.allDocs({ jio.allDocs({
query: "", query: "",
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}), }),
context.jio.allDocs({ jio.allDocs({
query: "title: version2", query: "title: version2",
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}), }),
context.jio.allDocs({ jio.allDocs({
query: "NOT (title: version1)", query: "NOT (title: version1)",
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}), }),
context.jio.allDocs({ jio.allDocs({
query: "(NOT (subtitle: subvers1)) AND (NOT (title: version0))", query: "(NOT (subtitle: subvers1)) AND (NOT (title: version0))",
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}), }),
context.jio.allDocs({ jio.allDocs({
limit: [0, 1], limit: [0, 1],
sort_on: [["title", "ascending"]], sort_on: [["title", "ascending"]],
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
...@@ -776,21 +776,22 @@ ...@@ -776,21 +776,22 @@
}) })
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
context.jio.allDocs({ jio.allDocs({
query: "_timestamp: " + timestamps[1], query: "_timestamp: " + timestamps.doc[1],
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}), }),
context.jio.allDocs({ jio.allDocs({
query: "_timestamp: =" + timestamps[1], query: "_timestamp: =" + timestamps.doc[1],
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}), }),
context.jio.allDocs({ jio.allDocs({
query: "_timestamp: >" + timestamps[0] + " AND title: version1", query: "_timestamp: >" + timestamps.doc[0] +
" AND title: version1",
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}), }),
context.jio.allDocs({ jio.allDocs({
query: "_timestamp: > " + timestamps[0] + " AND _timestamp: < " + query: "_timestamp: > " + timestamps.doc[0] +
timestamps[2], " AND _timestamp: < " + timestamps.doc[2],
select_list: ["title", "subtitle"] select_list: ["title", "subtitle"]
}) })
]); ]);
...@@ -817,20 +818,36 @@ ...@@ -817,20 +818,36 @@
}, },
doc: {} doc: {}
}); });
return jio.allDocs({
query: "_timestamp: " + timestamps.doc[0],
select_list: ["title", "subtitle"]
});
})
.push(function (results) {
deepEqual(results.data.rows, [
{
value: {
title: "version0",
subtitle: "subvers0"
},
doc: {},
id: "doc"
}
], "Query requesting one timestamp works.");
return context.not_history.allDocs({ return not_history.allDocs({
sort_on: [["title", "ascending"]] sort_on: [["title", "ascending"]]
}); });
}) })
.push(function (results) { .push(function (results) {
return RSVP.all(results.data.rows.map(function (d) { return RSVP.all(results.data.rows.map(function (d) {
return context.not_history.get(d.id); return not_history.get(d.id);
})); }));
}) })
.push(function (results) { .push(function (results) {
deepEqual(results, [ deepEqual(results, [
{ {
timestamp: timestamps[0], timestamp: timestamps.doc[0],
op: "put", op: "put",
doc_id: "doc", doc_id: "doc",
doc: { doc: {
...@@ -839,7 +856,7 @@ ...@@ -839,7 +856,7 @@
} }
}, },
{ {
timestamp: timestamps[1], timestamp: timestamps.doc[1],
op: "put", op: "put",
doc_id: "doc", doc_id: "doc",
doc: { doc: {
...@@ -848,7 +865,7 @@ ...@@ -848,7 +865,7 @@
} }
}, },
{ {
timestamp: timestamps[2], timestamp: timestamps.doc[2],
op: "put", op: "put",
doc_id: "doc", doc_id: "doc",
doc: { doc: {
......
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