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