1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-24 21:41:21 +00:00
haste-server/test/redis_document_store_spec.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-06-26 16:38:17 +00:00
/* global it, describe, afterEach */
var assert = require('assert');
2011-11-29 01:56:41 +00:00
var winston = require('winston');
winston.remove(winston.transports.Console);
var RedisDocumentStore = require('../lib/document_stores/redis');
describe('redis_document_store', function() {
2011-11-29 01:56:41 +00:00
/* reconnect to redis on each test */
afterEach(function() {
if (RedisDocumentStore.client) {
RedisDocumentStore.client.quit();
RedisDocumentStore.client = false;
}
});
2017-06-26 16:38:17 +00:00
describe('set', function() {
it('should be able to set a key and have an expiration set', function(done) {
var store = new RedisDocumentStore({ expire: 10 });
store.set('hello1', 'world', function() {
RedisDocumentStore.client.ttl('hello1', function(err, res) {
assert.ok(res > 1);
done();
});
});
});
it('should not set an expiration when told not to', function(done) {
var store = new RedisDocumentStore({ expire: 10 });
store.set('hello2', 'world', function() {
RedisDocumentStore.client.ttl('hello2', function(err, res) {
assert.equal(-1, res);
done();
});
}, true);
});
it('should not set an expiration when expiration is off', function(done) {
var store = new RedisDocumentStore({ expire: false });
2017-06-26 16:38:17 +00:00
store.set('hello3', 'world', function() {
RedisDocumentStore.client.ttl('hello3', function(err, res) {
assert.equal(-1, res);
done();
});
});
});
});
});