Commit 1631f6c5 authored by preetwinder's avatar preetwinder

error message change and remove unused variable

parent 9dfafb7f
...@@ -34,12 +34,17 @@ ...@@ -34,12 +34,17 @@
this._sub_storage = jIO.createJIO(description.sub_storage); this._sub_storage = jIO.createJIO(description.sub_storage);
this._database_name = "jio:" + description.database; this._database_name = "jio:" + description.database;
this._index_keys = description.index_keys || []; this._index_keys = description.index_keys || [];
this._version = 1;
} }
IndexStorage2.prototype.hasCapacity = function (name) { IndexStorage2.prototype.hasCapacity = function (name) {
return ((name === "list") || (name === "query")) || (name === "limit") || var this_storage_capacity_list = ["limit",
(name === "select"); "select",
"list",
"query"];
if (this_storage_capacity_list.indexOf(name) !== -1) {
return true;
}
}; };
function checkArrayEquality(array1, array2) { function checkArrayEquality(array1, array2) {
...@@ -221,10 +226,8 @@ ...@@ -221,10 +226,8 @@
try { try {
context._sub_storage.hasCapacity("query"); context._sub_storage.hasCapacity("query");
} catch (error) { } catch (error) {
throw new jIO.util.jIOError( throw new jIO.util.jIOError("No index for '" + index +
"No index for this key and substorage doesn't support queries", "' key and substorage doesn't support queries", 404);
404
);
} }
return context._sub_storage.buildQuery( return context._sub_storage.buildQuery(
{ "query": index + ":" + value } { "query": index + ":" + value }
......
...@@ -132,6 +132,7 @@ ...@@ -132,6 +132,7 @@
ok(this.jio.hasCapacity("list")); ok(this.jio.hasCapacity("list"));
ok(this.jio.hasCapacity("query")); ok(this.jio.hasCapacity("query"));
ok(this.jio.hasCapacity("limit")); ok(this.jio.hasCapacity("limit"));
ok(this.jio.hasCapacity("select"));
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -194,7 +195,7 @@ ...@@ -194,7 +195,7 @@
} }
}); });
stop(); stop();
expect(3); expect(4);
DummyStorage3.prototype.put = function (id, value) { DummyStorage3.prototype.put = function (id, value) {
equal(id, "32"); equal(id, "32");
...@@ -207,7 +208,8 @@ ...@@ -207,7 +208,8 @@
return context.jio.allDocs({query: 'a: "3"'}); return context.jio.allDocs({query: 'a: "3"'});
}) })
.then(function (result) { .then(function (result) {
deepEqual(result.data.rows[0], {"id": "32", "value": {}}); equal(result.data.total_rows, 1);
deepEqual(result.data.rows, [{"id": "32", "value": {}}]);
}) })
.fail(function (error) { .fail(function (error) {
console.log(error); console.log(error);
...@@ -298,7 +300,7 @@ ...@@ -298,7 +300,7 @@
.fail(function (error) { .fail(function (error) {
equal(error.status_code, 404); equal(error.status_code, 404);
equal(error.message, equal(error.message,
"No index for this key and substorage doesn't support queries"); "No index for 'b' key and substorage doesn't support queries");
}) })
.always(function () { .always(function () {
start(); start();
...@@ -731,7 +733,7 @@ ...@@ -731,7 +733,7 @@
}); });
}); });
test("Index keys modified", function () { test("Index keys are modified", function () {
var context = this; var context = this;
context.jio = jIO.createJIO({ context.jio = jIO.createJIO({
type: "index2", type: "index2",
...@@ -805,7 +807,7 @@ ...@@ -805,7 +807,7 @@
.fail(function (error) { .fail(function (error) {
equal(error.status_code, 404); equal(error.status_code, 404);
equal(error.message, equal(error.message,
"No index for this key and substorage doesn't support queries"); "No index for 'a' key and substorage doesn't support queries");
}) })
.always(function () { .always(function () {
start(); start();
......
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