CartoDB-SQL-API/test/unit/redis_pool.test.js
2012-07-13 10:29:09 +02:00

50 lines
1.4 KiB
JavaScript

require('../helper');
var _ = require('underscore')
, redis_pool = require('../../app/models/redis_pool')
, assert = require('assert');
suite('redis_pool', function() {
test('test truth', function(){
assert.ok(true, 'it is');
});
test('test can instantiate a RedisPool object', function(){
assert.ok(redis_pool);
});
test('test pool object has an aquire function', function(){
assert.ok(_.includes(_.functions(redis_pool), 'acquire'));
});
test('test calling aquire returns a redis client object that can get/set', function(done){
redis_pool.acquire(0, function(client){
client.set("key","value");
client.get("key", function(err,data){
assert.equal(data, "value");
redis_pool.release(0, client);
done();
});
});
});
test('test calling aquire on another DB returns a redis client object that can get/set', function(done){
redis_pool.acquire("MYDATABASE", function(client){
client.set("key","value");
client.get("key", function(err,data){
assert.equal(data, "value");
redis_pool.release("MYDATABASE", client);
redis_pool.acquire("MYDATABASE", function(client){
client.get("key", function(err,data){
assert.equal(data, "value");
redis_pool.release("MYDATABASE", client);
done();
});
});
})
});
});
});