You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-12-25 00:40:59 +03:00
Fix should_buffer return values and empty .batch and .auth return value being sync
Fix test
This commit is contained in:
@@ -128,12 +128,15 @@ describe("client authentication", function () {
|
||||
if (helper.redisProcess().spawnFailed()) this.skip();
|
||||
|
||||
client = redis.createClient.apply(redis.createClient, args);
|
||||
var async = true;
|
||||
client.auth(undefined, function(err, res) {
|
||||
assert.strictEqual(err.message, 'The password has to be of type "string"');
|
||||
assert.strictEqual(err.command, 'AUTH');
|
||||
assert.strictEqual(res, undefined);
|
||||
async = false;
|
||||
done();
|
||||
});
|
||||
assert(async);
|
||||
});
|
||||
|
||||
it('should emit an error if the password is not of type string and no callback has been provided', function (done) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var config = require("../lib/config");
|
||||
var helper = require('../helper');
|
||||
var config = require("./lib/config");
|
||||
var helper = require('./helper');
|
||||
var redis = config.redis;
|
||||
var uuid = require('uuid');
|
||||
|
||||
@@ -52,7 +52,7 @@ describe("The 'batch' method", function () {
|
||||
|
||||
beforeEach(function (done) {
|
||||
client = redis.createClient.apply(redis.createClient, args);
|
||||
client.once("connect", function () {
|
||||
client.once("ready", function () {
|
||||
client.flushdb(function (err) {
|
||||
return done(err);
|
||||
});
|
||||
@@ -63,6 +63,19 @@ describe("The 'batch' method", function () {
|
||||
client.end();
|
||||
});
|
||||
|
||||
it("returns an empty result array", function (done) {
|
||||
var batch = client.batch();
|
||||
var async = true;
|
||||
var notBuffering = batch.exec(function (err, res) {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(res.length, 0);
|
||||
async = false;
|
||||
done();
|
||||
});
|
||||
assert(async);
|
||||
assert.strictEqual(notBuffering, true);
|
||||
});
|
||||
|
||||
it('fail individually when one command fails using chaining notation', function (done) {
|
||||
var batch1, batch2;
|
||||
batch1 = client.batch();
|
||||
@@ -216,8 +229,7 @@ describe("The 'batch' method", function () {
|
||||
|
||||
it('runs a batch without any further commands and without callback', function() {
|
||||
var buffering = client.batch().exec();
|
||||
assert(typeof buffering === 'boolean');
|
||||
assert(!buffering);
|
||||
assert.strictEqual(buffering, true);
|
||||
});
|
||||
|
||||
it('allows batchple operations to be performed using a chaining API', function (done) {
|
||||
@@ -32,11 +32,12 @@ describe("The 'multi' method", function () {
|
||||
});
|
||||
|
||||
it("reports an error", function (done) {
|
||||
client.multi();
|
||||
client.exec(function (err, res) {
|
||||
var multi = client.multi();
|
||||
var notBuffering = multi.exec(function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
done();
|
||||
});
|
||||
assert.strictEqual(notBuffering, false);
|
||||
});
|
||||
|
||||
it("reports an error if promisified", function () {
|
||||
@@ -51,7 +52,7 @@ describe("The 'multi' method", function () {
|
||||
|
||||
beforeEach(function (done) {
|
||||
client = redis.createClient.apply(redis.createClient, args);
|
||||
client.once("connect", function () {
|
||||
client.once("ready", function () {
|
||||
client.flushdb(function (err) {
|
||||
return done(err);
|
||||
});
|
||||
@@ -62,6 +63,16 @@ describe("The 'multi' method", function () {
|
||||
client.end();
|
||||
});
|
||||
|
||||
it("returns an empty result array", function (done) {
|
||||
var multi = client.multi();
|
||||
var notBuffering = multi.exec(function (err, res) {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(res.length, 0);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual(notBuffering, true);
|
||||
});
|
||||
|
||||
it('roles back a transaction when one command in a sequence of commands fails', function (done) {
|
||||
var multi1, multi2;
|
||||
var expected = helper.serverVersionAtLeast(client, [2, 6, 5]) ? helper.isError() : function () {};
|
||||
|
||||
Reference in New Issue
Block a user