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

Add the redis url to the options object and accept .createClient(null, host, options)

This commit is contained in:
Ruben Bridgewater
2015-11-22 22:48:13 +01:00
parent 30d2184dbb
commit 8f9ad00de2
4 changed files with 64 additions and 13 deletions

View File

@@ -263,6 +263,20 @@ describe("connection tests", function () {
});
});
it("connects correctly to the provided host with the port set to null", function (done) {
client = redis.createClient(null, 'localhost');
client.on("error", done);
assert.strictEqual(client.address, 'localhost:6379');
client.once("ready", function () {
client.set('foo', 'bar');
client.get('foo', function(err, res) {
assert.strictEqual(res, 'bar');
done(err);
});
});
});
it("connects correctly to localhost and no ready check", function (done) {
client = redis.createClient(undefined, undefined, {
no_ready_check: true
@@ -278,6 +292,22 @@ describe("connection tests", function () {
});
});
it("connects correctly to the provided host with the port set to undefined", function (done) {
client = redis.createClient(undefined, 'localhost', {
no_ready_check: true
});
client.on("error", done);
assert.strictEqual(client.address, 'localhost:6379');
client.once("ready", function () {
client.set('foo', 'bar');
client.get('foo', function(err, res) {
assert.strictEqual(res, 'bar');
done(err);
});
});
});
it("connects correctly even if the info command is not present on the redis server", function (done) {
client = redis.createClient.apply(redis.createClient, args);
client.info = function (cb) {
@@ -327,6 +357,28 @@ describe("connection tests", function () {
});
});
it('allows connecting with the redis url as first parameter and the options as second parameter', function (done) {
client = redis.createClient('redis://127.0.0.1', {
connect_timeout: 1000
});
assert.strictEqual(client.options.connect_timeout, 1000);
client.on('ready', function () {
done();
});
});
it('allows connecting with the redis url in the options object', function (done) {
client = redis.createClient({
url: 'redis://foo:porkchopsandwiches@' + config.HOST[ip]
});
assert.strictEqual(client.options.auth_pass, 'porkchopsandwiches');
assert(!client.options.port);
assert.strictEqual(client.options.host, config.HOST[ip]);
client.on("ready", function () {
return done();
});
});
it('allows connecting with the redis url and no auth and options as second parameter', function (done) {
var options = {
detect_buffers: false