Commit 3598f85f authored by Bryan Kaperick's avatar Bryan Kaperick

Fixed the query test so now all test assertions run and pass.

parent a1a1117d
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
*/ */
function BryanStorage(spec) { function BryanStorage(spec) {
//this._sub_storage = jIO.createJIO(spec.sub_storage); //this._sub_storage = jIO.createJIO(spec.sub_storage);
this._sub_storage = jIO.createJIO({ this._sub_storage = jIO.createJIO({
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
sort_on: [['_revision', 'descending']] sort_on: [['_revision', 'descending']]
//include_docs: true //include_docs: true
}; };
return this.allDocs(options) return substorage.allDocs(options)
// Return query results if there are any, else throw error // Return query results if there are any, else throw error
.push(function (query_results) { .push(function (query_results) {
var docs = query_results.data.rows; var docs = query_results.data.rows;
...@@ -70,8 +71,9 @@ ...@@ -70,8 +71,9 @@
); );
}; };
BryanStorage.prototype.allDocs = function () { BryanStorage.prototype.allDocs = function (options) {
return this._sub_storage.allDocs.apply(this._sub_storage, arguments); //console.log(options);
return this._sub_storage.allDocs.apply(this._sub_storage, options);
}; };
BryanStorage.prototype.allAttachments = function () { BryanStorage.prototype.allAttachments = function () {
...@@ -134,8 +136,8 @@ ...@@ -134,8 +136,8 @@
BryanStorage.prototype.repair = function () { BryanStorage.prototype.repair = function () {
return this._sub_storage.repair.apply(this._sub_storage, arguments); return this._sub_storage.repair.apply(this._sub_storage, arguments);
}; };
BryanStorage.prototype.hasCapacity = function (name) { BryanStorage.prototype.hasCapacity = function () {
return this._sub_storage.removeAttachment.apply(this._sub_storage, name); return this._sub_storage.hasCapacity.apply(this._sub_storage, arguments);
}; };
BryanStorage.prototype.buildQuery = function () { BryanStorage.prototype.buildQuery = function () {
return this._sub_storage.buildQuery.apply(this._sub_storage, arguments); return this._sub_storage.buildQuery.apply(this._sub_storage, arguments);
......
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
type: "bryan", type: "bryan",
sub_storage: { sub_storage: {
type: "memory" type: "memory"
//database: "newdb4"
} }
}); });
jio.put("doc1", { jio.put("doc1", {
...@@ -84,12 +83,17 @@ ...@@ -84,12 +83,17 @@
type: "bryan", type: "bryan",
sub_storage: { sub_storage: {
type: "memory" type: "memory"
//database: "otherdb8"
} }
}); });
jio.put("other_doc", { jio.put("main_doc", {
"title": "rev0",
"subtitle": "subrev0"
})
.push(function () {
return jio.put("other_doc", {
"attr": "version0", "attr": "version0",
"subattr": "subversion0" "subattr": "subversion0"
});
}) })
.push(function () { .push(function () {
return jio.put("other_doc", { return jio.put("other_doc", {
...@@ -97,12 +101,6 @@ ...@@ -97,12 +101,6 @@
"subattr": "subversion1" "subattr": "subversion1"
}); });
}) })
.push(function () {
return jio.put("main_doc", {
"title": "rev0",
"subtitle": "subrev0"
});
})
.push(function () { .push(function () {
return jio.put("main_doc", { return jio.put("main_doc", {
"title": "rev1", "title": "rev1",
...@@ -133,8 +131,9 @@ ...@@ -133,8 +131,9 @@
"_doc_id": "other_doc" "_doc_id": "other_doc"
}, "Retrieve other document correctly"); }, "Retrieve other document correctly");
}) })
.push(function () { .push(function () {
return jio.allDocs({ return jio.buildQuery({
query: '(_doc_id: "main_doc") AND (_revision: 0)', query: '(_doc_id: "main_doc") AND (_revision: 0)',
sort_on: [['_revision', 'descending']] sort_on: [['_revision', 'descending']]
}); });
...@@ -143,7 +142,7 @@ ...@@ -143,7 +142,7 @@
equal(result.length, 1, "Correct number of results returned"); equal(result.length, 1, "Correct number of results returned");
}) })
.push(function () { .push(function () {
return jio.allDocs({ return jio.buildQuery({
query: '(_doc_id: "main_doc") AND (_revision: 1)' query: '(_doc_id: "main_doc") AND (_revision: 1)'
}); });
}) })
...@@ -151,7 +150,7 @@ ...@@ -151,7 +150,7 @@
equal(result.length, 1, "Correct number of results returned"); equal(result.length, 1, "Correct number of results returned");
}) })
.push(function () { .push(function () {
return jio.allDocs({ return jio.buildQuery({
query: '(_doc_id: "other_doc") AND (_revision: 0)' query: '(_doc_id: "other_doc") AND (_revision: 0)'
}); });
}) })
...@@ -159,7 +158,7 @@ ...@@ -159,7 +158,7 @@
equal(result.length, 1, "Correct number of results returned"); equal(result.length, 1, "Correct number of results returned");
}) })
.push(function () { .push(function () {
return jio.allDocs({ return jio.buildQuery({
query: '' query: ''
}); });
}) })
...@@ -167,6 +166,7 @@ ...@@ -167,6 +166,7 @@
equal(result.length, 5, "Correct number of results returned"); equal(result.length, 5, "Correct number of results returned");
}) })
.fail(function (error) { .fail(function (error) {
//console.log(error);
ok(false, error); ok(false, error);
}) })
.always(function () { .always(function () {
......
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