Created
February 23, 2012 11:47
-
-
Save sreeix/1892518 to your computer and use it in GitHub Desktop.
Fake Redis in test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testy = require('../testy') | |
var RedisProxy = require('../../lib/redis_proxy') | |
describe('RedisProxy', function() { | |
it('raises exception when no rediss available', function() { | |
(function(){ | |
new RedisProxy({}) | |
}).should.throw(); | |
}); | |
it('should proxy existing redis', function() { | |
var fake = testy.createRedis(6389); | |
(function() { | |
new RedisProxy({"servers": [{"host": "localhost","port": 6389}]}) | |
}).should.not.throw(); | |
fake.close(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
exports.createRedis = function(port){ | |
var server = net.createServer(function (socket) { | |
socket.on('end', function() { | |
console.log('disconnect'); | |
}); | |
socket.on('data', function(data) { | |
console.log("DATA: "+data); | |
}); | |
}); | |
server.listen(port); | |
return server; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment