Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call callback after selecting database #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 4 additions & 7 deletions lib/redis-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,10 @@ RedisClient.prototype.send_command = RedisClient.prototype.SEND_COMMAND = functi
}
}

RedisClient.prototype.select = function (database) {

RedisClient.prototype.select = function (database, callback) {
if (callback) {
process.nextTick(callback(null, "OK"));
}
return "OK";
}

Expand All @@ -417,8 +419,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