Skip to content

Commit

Permalink
Merge pull request #208 from wpreul/develop
Browse files Browse the repository at this point in the history
Fixing failing ttl tests
  • Loading branch information
Eran Hammer-Lahav committed Nov 1, 2012
2 parents c404788 + e18a48f commit 3d125ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 1 addition & 3 deletions lib/cache/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,4 @@ exports.ttl = function (rule, created) {
}

return 0; // Bad rule
};


};
10 changes: 3 additions & 7 deletions test/unit/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,23 +522,19 @@ require('../suite')(function (useRedis, useMongo) {
var config = {
expiresAt: '13:00'
};
var created = new Date(Date.now());
created.setHours(15);
created = new Date(created.setDate(created.getDay() - 4)).getTime();
var created = Date.now() - 313200000; // 87 hours (3 days + 15 hours)
var rule = Cache.compile(config);

var ttl = Cache.ttl(rule, created);
expect(ttl).to.equal(0);
done();
});

it('returns the 0 when created several days ago and expiresAt is used with an hour before the created hour', function (done) {
it('returns 0 when created 60 hours ago and expiresAt is used with an hour before the created hour', function (done) {
var config = {
expiresAt: '12:00'
};
var created = new Date(Date.now());
created.setHours(10);
created = new Date(created.setDate(created.getDay() - 4)).getTime();
var created = Date.now() - 342000000; // 95 hours ago (3 days + 23 hours)
var rule = Cache.compile(config);

var ttl = Cache.ttl(rule, created);
Expand Down

0 comments on commit 3d125ac

Please sign in to comment.