Remove hashlib dependency and switch to mocha for testing
This commit is contained in:
parent
b251978422
commit
6e4c087319
7 changed files with 42 additions and 65 deletions
|
@ -15,73 +15,34 @@ describe('redis_document_store', function() {
|
|||
|
||||
describe('set', function() {
|
||||
|
||||
it('should be able to set a key and have an expiration set', function() {
|
||||
it('should be able to set a key and have an expiration set', function(done) {
|
||||
var store = new RedisDocumentStore({ expire: 10 });
|
||||
runs(function() {
|
||||
var _this = this;
|
||||
store.set('hello1', 'world', function(worked) {
|
||||
_this.result = worked;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return typeof(this.result) === 'boolean';
|
||||
});
|
||||
runs(function() {
|
||||
var _this = this;
|
||||
store.set('hello1', 'world', function() {
|
||||
RedisDocumentStore.client.ttl('hello1', function(err, res) {
|
||||
expect(res).toBeGreaterThan(1);
|
||||
_this.done = true;
|
||||
res.should.be.above(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return this.done;
|
||||
});
|
||||
});
|
||||
|
||||
it('should not set an expiration when told not to', function() {
|
||||
it('should not set an expiration when told not to', function(done) {
|
||||
var store = new RedisDocumentStore({ expire: 10 });
|
||||
runs(function() {
|
||||
var _this = this;
|
||||
store.set('hello2', 'world', function(worked) {
|
||||
_this.result = worked;
|
||||
}, true);
|
||||
});
|
||||
waitsFor(function() {
|
||||
return typeof(this.result) === 'boolean';
|
||||
});
|
||||
runs(function() {
|
||||
var _this = this;
|
||||
store.set('hello2', 'world', function() {
|
||||
RedisDocumentStore.client.ttl('hello2', function(err, res) {
|
||||
expect(res).toBe(-1);
|
||||
_this.done = true;
|
||||
res.should.equal(-1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return this.done;
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
|
||||
it('should not set an expiration when expiration is off', function() {
|
||||
it('should not set an expiration when expiration is off', function(done) {
|
||||
var store = new RedisDocumentStore({ expire: false });
|
||||
runs(function() {
|
||||
var _this = this;
|
||||
store.set('hello3', 'world', function(worked) {
|
||||
_this.result = worked;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return typeof(this.result) === 'boolean';
|
||||
});
|
||||
runs(function() {
|
||||
var _this = this;
|
||||
store.set('hello3', 'world', function(worked) {
|
||||
RedisDocumentStore.client.ttl('hello3', function(err, res) {
|
||||
expect(res).toBe(-1);
|
||||
_this.done = true;
|
||||
res.should.equal(-1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return this.done;
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue