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

Remove async dependency

This commit is contained in:
Ruben Bridgewater
2015-09-04 17:05:38 +02:00
parent c947e8ff3a
commit 43e25e73c9
4 changed files with 24 additions and 47 deletions

View File

@@ -16,7 +16,6 @@
"jshint": "./node_modules/.bin/jshint *"
},
"devDependencies": {
"async": "^1.3.0",
"coveralls": "^2.11.2",
"hiredis": "^0.4.1",
"jshint": "^2.8.0",

View File

@@ -1,6 +1,5 @@
'use strict';
var async = require('async');
var assert = require('assert');
var config = require("../lib/config");
var helper = require('../helper');
@@ -57,29 +56,16 @@ describe("The 'flushdb' method", function () {
});
describe("when there is data in Redis", function () {
var oldSize;
beforeEach(function (done) {
async.parallel([function (next) {
client.mset(key, uuid.v4(), key2, uuid.v4(), function (err, res) {
helper.isNotError()(err, res);
next(err);
});
}, function (next) {
client.dbsize([], function (err, res) {
helper.isType.positiveNumber()(err, res);
oldSize = res;
next(err);
});
}], function (err) {
if (err) {
return done(err);
}
client.FLUSHDB(function (err, res) {
helper.isString("OK")(err, res);
done(err);
});
var end = helper.callFuncAfter(function () {
client.flushdb(helper.isString("OK", done));
}, 2);
client.mset(key, uuid.v4(), key2, uuid.v4(), helper.isNotError(end));
client.dbsize([], function (err, res) {
helper.isType.positiveNumber()(err, res);
assert.equal(res, 2, 'Two keys should have been inserted');
end();
});
});

View File

@@ -116,5 +116,14 @@ module.exports = {
var mochaListener = process.listeners('uncaughtException').pop();
process.removeListener('uncaughtException', mochaListener);
return mochaListener;
},
callFuncAfter: function (func, max) {
var i = 0;
return function () {
i++;
if (i === max) {
func();
}
};
}
};

View File

@@ -1,6 +1,5 @@
'use strict';
var async = require("async");
var assert = require("assert");
var config = require("./lib/config");
var helper = require('./helper');
@@ -122,31 +121,15 @@ describe("The node_redis client", function () {
it("reconnects and can retrieve the pre-existing data", function (done) {
client.on("reconnecting", function on_recon(params) {
client.on("connect", function on_connect() {
async.parallel([function (cb) {
client.get("recon 1", function (err, res) {
helper.isString("one")(err, res);
cb();
});
}, function (cb) {
client.get("recon 1", function (err, res) {
helper.isString("one")(err, res);
cb();
});
}, function (cb) {
client.get("recon 2", function (err, res) {
helper.isString("two")(err, res);
cb();
});
}, function (cb) {
client.get("recon 2", function (err, res) {
helper.isString("two")(err, res);
cb();
});
}], function (err, results) {
var end = helper.callFuncAfter(function () {
client.removeListener("connect", on_connect);
client.removeListener("reconnecting", on_recon);
done(err);
});
done();
}, 4);
client.get("recon 1", helper.isString("one", end));
client.get("recon 1", helper.isString("one", end));
client.get("recon 2", helper.isString("two", end));
client.get("recon 2", helper.isString("two", end));
});
});