Fix flaky test4 (#7212)

* Increase timeout for redis tests

* Remove for

* Increase little bit more one of the tests since it requires two calls to be done in time-fahsion way

* increase default ttl a bit more
This commit is contained in:
Antonio Davi Macedo Coelho de Castro
2021-02-20 11:32:55 -08:00
committed by GitHub
parent fd3c7fc1de
commit a649a9e600

View File

@@ -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)
@@ -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 => {
@@ -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))
);
@@ -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)
@@ -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(() => {