Skip to content

Commit

Permalink
[Unit-tests] fix
Browse files Browse the repository at this point in the history
  • Loading branch information
FGRibreau committed Feb 22, 2014
1 parent 4bb71b4 commit 5f4acb9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"scripts": {
"start": "node ./bin/redsmin",
"test": "nodeunit test/*.js"
"test": "nodeunit test/*.test.js"
},
"bin": {
"redsmin": "./bin/redsmin"
Expand All @@ -32,8 +32,8 @@
}
],
"dependencies": {
"lodash": "~0.3.2",
"winston": "~0.6.1",
"lodash": "~2.4.1",
"winston": "~0.7.2",
"backoff": "0.0.2",
"daemonize2": "~0.4.0-rc.5"
},
Expand Down
19 changes: 6 additions & 13 deletions test/Endpoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ var Endpoint = require('../lib/Endpoint')
, _ = require('lodash')
, fs = require('fs')
, sinon = require('sinon')
, jsonPackage = JSON.parse(fs.readFileSync(__dirname + '/../package.json'));

function noop(){}
, jsonPackage = JSON.parse(fs.readFileSync(__dirname + '/../package.json'))
, Socket = require('./helpers/Socket');

function tconnect(t, host, hostname, fnWriteStub){
return function(_host, _hostname, cb){
Expand All @@ -15,19 +14,13 @@ function tconnect(t, host, hostname, fnWriteStub){

process.nextTick(cb);

return _.extend({
write: fnWriteStub || noop
, setTimeout:noop
, setNoDelay:noop
, destroy:noop
, setKeepAlive:noop
}, new (require('events').EventEmitter)());
return new Socket(fnWriteStub);
};
}


function stubLocalClient(fn){
return fn || noop;
return fn || _.noop;
}

// Quiet console output
Expand All @@ -41,9 +34,9 @@ exports['Endpoint'] = {

// Mock console
Endpoint.log = _.reduce(console, function(m, v, k){
m[k] = noop;
m[k] = _.noop;
return m;
}, {debug:noop});
}, {debug:_.noop});

done();
},
Expand Down
11 changes: 3 additions & 8 deletions test/RedisClient.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var RedisClient = require('../lib/RedisClient')
, _ = require('lodash')
, sinon = require('sinon');
, sinon = require('sinon')
, Socket = require('./helpers/Socket');

function tcreateConnection(t, host, hostname){
return function(_host, _hostname, cb){
Expand All @@ -10,13 +11,7 @@ function tcreateConnection(t, host, hostname){
}
cb();

return _.extend({
write: function(){}
, destroy:function(){}
, setKeepAlive:function(){}
, setNoDelay:function(){}
, setTimeout:function(){}
}, new (require('events').EventEmitter)());
return new Socket();
};
}

Expand Down
16 changes: 16 additions & 0 deletions test/helpers/Socket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var EventEmitter = require('events').EventEmitter
, _ = require('lodash')
, util = require('util');

function Socket(fnWriteStub){
EventEmitter.call(this);
this.write = fnWriteStub || _.noop;
this.setTimeout = _.noop;
this.setNoDelay = _.noop;
this.destroy = _.noop;
this.setKeepAlive = _.noop;
}

util.inherits(Socket, EventEmitter);

module.exports = Socket;

0 comments on commit 5f4acb9

Please sign in to comment.