Skip to content

Commit

Permalink
Merge pull request #32 from alexkvak/test/increase-redis-timeout
Browse files Browse the repository at this point in the history
test: increase timeout for redis
  • Loading branch information
alexkvak authored Jun 24, 2020
2 parents 13ae88e + 32d143a commit 87f70e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/integration/base-redis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import RedisStorageAdapter from "../../src/adapters/RedisStorageAdapter";
import { BaseStorage } from "../../src/storage/BaseStorage";

const redis = new Redis();
const adapter = new RedisStorageAdapter(redis);
const adapter = new RedisStorageAdapter(redis, { operationTimeout: 9000 });
const prefix = "cache";
const storage = new BaseStorage({ adapter, prefix });

Expand Down
16 changes: 9 additions & 7 deletions tests/integration/cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const redis = new Redis({
autoResendUnfulfilledCommands: false,
});
const cache = new Cache({
adapter: new RedisStorageAdapter(redis),
adapter: new RedisStorageAdapter(redis, { operationTimeout: 9000 }),
logger,
});

const REDIS_OPERATION_DELAY = 1000;

describe("Cache", () => {
beforeEach(
() =>
Expand Down Expand Up @@ -58,7 +60,7 @@ describe("Cache", () => {
const key = uuid();

await expect(cache.get(key, () => struct)).resolves.toEqual(struct);
await timeout(100);
await timeout(REDIS_OPERATION_DELAY);
await expect(cache.get(key, jest.fn)).resolves.toEqual(struct);
});

Expand All @@ -68,7 +70,7 @@ describe("Cache", () => {

await cache.set(key, struct);
redis.disconnect();
await timeout(100);
await timeout(REDIS_OPERATION_DELAY);
await expect(cache.get(key, async () => struct)).resolves.toEqual(struct);
});

Expand All @@ -81,7 +83,7 @@ describe("Cache", () => {

await cache.set(key, struct);
redis.disconnect();
await timeout(100);
await timeout(REDIS_OPERATION_DELAY);
await expect(cache.get(key, executor)).rejects.toThrowErrorMatchingInlineSnapshot(
`"connection timed out"`
);
Expand All @@ -93,7 +95,7 @@ describe("Cache", () => {
const key = uuid();

await expect(cache.get(key, () => struct, { tags })).resolves.toEqual(struct);
await timeout(100);
await timeout(REDIS_OPERATION_DELAY);
await expect(cache.get(key, jest.fn, { tags })).resolves.toEqual(struct);
});

Expand All @@ -104,10 +106,10 @@ describe("Cache", () => {
const key = uuid();

await expect(cache.get(key, executor, { tags })).resolves.toEqual(struct);
await timeout(100);
await timeout(REDIS_OPERATION_DELAY);
await expect(cache.get(key, jest.fn, { tags })).resolves.toEqual(struct);
await cache.touch(tags);
await timeout(50);
await timeout(REDIS_OPERATION_DELAY);

struct.a = 5;

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/redis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import RedisStorageAdapter from "../../src/adapters/RedisStorageAdapter";
import { runAdapterTests } from "./adapter-agnostic";

const redis = new Redis();
const adapter = new RedisStorageAdapter(redis, { lockExpireTimeout: 50, operationTimeout: 4000 });
const adapter = new RedisStorageAdapter(redis, { lockExpireTimeout: 50, operationTimeout: 9000 });

describe("Redis adapter", () => {
beforeEach(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ module.exports = {
transform: {
'^.+\\.ts$': 'ts-jest',
},
testTimeout: 10000,
};

0 comments on commit 87f70e0

Please sign in to comment.