Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing failing ttl tests #208

Merged
merged 1 commit into from
Nov 1, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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