You've already forked node-redis
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user