1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Fix bug in mocha tests Redis shutdown which expected exit code to eq 0.

Move a miscategorized select test into the correct describe.
This commit is contained in:
Erin Spiceland
2015-07-14 09:45:48 -05:00
committed by Benjamin Coe
parent 5da083322d
commit 3aaef47756
3 changed files with 37 additions and 34 deletions

View File

@@ -23,7 +23,9 @@ module.exports = {
stop: function (done) {
rp.once("exit", function (code) {
var error = null;
if (code !== 0) error = Error('failed to shutdown redis');
if (code !== null && code !== 0) {
error = Error('Redis shutdown failed with code ' + code);
}
return done(error);
});
rp.kill("SIGINT");

View File

@@ -70,6 +70,28 @@ describe("The 'select' method", function () {
});
});
describe("and a callback is specified", function () {
describe("with a valid db index", function () {
it("selects the appropriate database", function (done) {
assert.strictEqual(client.selected_db, null, "default db should be null");
client.select(1, function () {
assert.equal(client.selected_db, 1, "we should have selected the new valid DB");
return done();
});
});
});
describe("with an invalid db index", function () {
it("emits an error", function (done) {
assert.strictEqual(client.selected_db, null, "default db should be null");
client.select(9999, function (err) {
assert.equal(err.message, 'ERR invalid DB index')
return done();
});
});
});
});
describe("and no callback is specified", function () {
describe("with a valid db index", function () {
it("selects the appropriate database", function (done) {
@@ -83,14 +105,6 @@ describe("The 'select' method", function () {
});
describe("with an invalid db index", function () {
it("emits an error", function (done) {
assert.strictEqual(client.selected_db, null, "default db should be null");
client.select(9999, function (err) {
assert.equal(err.message, 'ERR invalid DB index')
return done();
});
});
it("throws an error when callback not provided", function (done) {
var mochaListener = removeMochaListener();
assert.strictEqual(client.selected_db, null, "default db should be null");

View File

@@ -938,19 +938,6 @@ tests.socket_nodelay = function () {
c3.on("ready", ready_check);
};
tests.select_error_emits_if_no_callback = function () {
var prev = client.listeners("error")[0];
client.removeListener("error", prev);
var name = "select_error_emits_if_no_callback";
var handler = with_timeout(name, function (err) {
require_error(name)(err);
client.removeListener('error', handler);
client.on("error", prev);
next(name);
}, 500);
client.on('error', handler);
client.select(9999);
};
tests.idle = function () {
var name = "idle";