1
0
Fork 0
mirror of https://github.com/SunRed/haste-server.git synced 2024-11-23 17:50:19 +01:00
haste-server/test/redis_document_store_spec.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-06-26 18:38:17 +02:00
/* global it, describe, afterEach */
2020-08-26 04:54:58 +02:00
const assert = require('assert');
2020-08-26 04:54:58 +02:00
const winston = require('winston');
2011-11-29 02:56:41 +01:00
winston.remove(winston.transports.Console);
2020-08-26 04:54:58 +02:00
const RedisDocumentStore = require('../lib/document_stores/redis');
2020-08-28 04:39:03 +02:00
describe('redis_document_store', function(){
/* reconnect to redis on each test */
afterEach(function(){
if (RedisDocumentStore.client){
RedisDocumentStore.client.quit();
RedisDocumentStore.client = false;
}
});
describe('set', function(){
it('should be able to set a key and have an expiration set', function(done){
let 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){
let 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){
let store = new RedisDocumentStore({ expire: false });
store.set('hello3', 'world', function(){
RedisDocumentStore.client.ttl('hello3', function(err, res){
assert.equal(-1, res);
done();
});
});
});
});
});