Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions lib/redis-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ RedisClient.prototype.send_command = RedisClient.prototype.SEND_COMMAND = functi
}
}

RedisClient.prototype.select = function (database) {

RedisClient.prototype.select = function (database, callback) {
process.nextTick(callback);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (callback) process.nextTick(callback(null,"OK"));

return "OK";
}

Expand All @@ -417,8 +417,3 @@ RedisMock.prototype.createClient = function (port_arg, host_arg, options) {

return new RedisClient();
}





13 changes: 11 additions & 2 deletions test/redis-mock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ describe("redis-mock", function () {

});

it("should call a callback when selecting a database", function (done) {
var r = redismock.createClient();

r.select(0, function(error) {
should.not.exist(error);
done();
});
});

it("should emit ready and connected when creating client", function (done) {

var r = redismock.createClient();
Expand Down Expand Up @@ -85,13 +94,13 @@ describe("redis-mock", function () {

describe("redis-error-mock", function () {
it("should emit a connection error", function (done) {

// Skip this when testing against actual Redis
if (process.env['VALID_TESTS']) {
done();
return;
}

var redis = new redismock.RedisErrorMock();

var r = redis.createClient();
Expand Down