Remove hashlib dependency and switch to mocha for testing

This commit is contained in:
John Crepezzi 2012-01-13 11:16:42 -05:00
parent b251978422
commit 6e4c087319
7 changed files with 42 additions and 65 deletions

View file

@ -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;
});
});
});