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

Fix flaky test4 #7212

Merged
merged 4 commits into from
Feb 20, 2021
Merged
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
18 changes: 9 additions & 9 deletions spec/RedisCacheAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ describe_only(() => {
});

it('should expire after ttl', done => {
const cache = new RedisCacheAdapter(null, 50);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(wait.bind(null, 52))
.then(wait.bind(null, 102))
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(null))
.then(done);
});

it('should not store value for ttl=0', done => {
const cache = new RedisCacheAdapter(null, 5);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE, 0)
Expand All @@ -57,20 +57,20 @@ describe_only(() => {
});

it('should not expire when ttl=Infinity', done => {
const cache = new RedisCacheAdapter(null, 1);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE, Infinity)
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(wait.bind(null, 5))
.then(wait.bind(null, 102))
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(done);
});

it('should fallback to default ttl', done => {
const cache = new RedisCacheAdapter(null, 1);
const cache = new RedisCacheAdapter(null, 100);
let promise = Promise.resolve();

[-100, null, undefined, 'not number', true].forEach(ttl => {
Expand All @@ -79,7 +79,7 @@ describe_only(() => {
.put(KEY, VALUE, ttl)
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(wait.bind(null, 5))
.then(wait.bind(null, 102))
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(null))
);
Expand All @@ -89,7 +89,7 @@ describe_only(() => {
});

it('should find un-expired records', done => {
const cache = new RedisCacheAdapter(null, 5);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE)
Expand All @@ -102,7 +102,7 @@ describe_only(() => {
});

it('handleShutdown, close connection', async () => {
const cache = new RedisCacheAdapter(null, 5);
const cache = new RedisCacheAdapter(null, 100);

await cache.handleShutdown();
setTimeout(() => {
Expand Down