Skip to content

Commit

Permalink
tests: end redis client open handles
Browse files Browse the repository at this point in the history
The "scan all cursor" test suite still causes open handle errors. These are specific to the test
suite and persist when test suite ordering is changed.
  • Loading branch information
bchrobot committed Sep 7, 2020
1 parent bc23715 commit fb5f154
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lib/memoizer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ describe('basic functionality', () => {
await memoizedFunction(args);
await memoizedFunction(args);
expect(mock).toHaveBeenCalledTimes(1);

await memoizer.quit();
});

test('should distinguish different args', async () => {
Expand All @@ -68,6 +70,8 @@ describe('basic functionality', () => {
await memoizedFunction({ a: 1 });
await memoizedFunction({ a: 2 });
expect(mock).toHaveBeenCalledTimes(2);

await memoizer.quit();
});

test('should lock duplicate calls', async () => {
Expand All @@ -87,6 +91,8 @@ describe('basic functionality', () => {

await Promise.all([memoizedFunction({ a: 1 }), memoizedFunction({ a: 1 })]);
expect(mock).toHaveBeenCalledTimes(1);

await memoizer.quit();
});
});

Expand Down Expand Up @@ -118,6 +124,8 @@ describe('invalidation', () => {
await memoizer.invalidate('basic-invalidate', args);
await memoizedFunction(args);
expect(mock).toHaveBeenCalledTimes(2);

await memoizer.quit();
});

test('should call once if different arg is invalidated', async () => {
Expand All @@ -138,6 +146,8 @@ describe('invalidation', () => {
await memoizer.invalidate('basic-invalidate', { a: 5 });
await memoizedFunction({ a: 4 });
expect(mock).toHaveBeenCalledTimes(1);

await memoizer.quit();
});

test('should call twice if different compound covered invalidate', async () => {
Expand All @@ -158,6 +168,8 @@ describe('invalidation', () => {
await memoizer.invalidate('compound-covered-invalidate', { a: 1 });
await memoizedFunction({ a: 1, b: 2 });
expect(mock).toHaveBeenCalledTimes(2);

await memoizer.quit();
});

test('should call once if invalidation is partially wrong', async () => {
Expand All @@ -178,6 +190,8 @@ describe('invalidation', () => {
await memoizer.invalidate('compound-missed-invalidate', { a: 1, b: 3 });
await memoizedFunction({ a: 1, b: 2 });
expect(mock).toHaveBeenCalledTimes(1);

await memoizer.quit();
});
});

Expand Down Expand Up @@ -205,6 +219,9 @@ describe('prefixes', () => {
await bF({ a: 1 });

expect(mock).toHaveBeenCalledTimes(2);

await a.quit();
await b.quit();
});
});

Expand All @@ -226,6 +243,8 @@ describe('empty mode', () => {
await memoizedFunction({ a: 1 });
await memoizedFunction({ a: 1 });
expect(mock).toHaveBeenCalledTimes(2);

await memoizer.quit();
});
});

Expand Down Expand Up @@ -254,5 +273,7 @@ describe('scan all cursor', () => {
await m.invalidate('scan-all-delete', { same: true });
await memoizedFunction({ n: 1, same: true });
expect(mock).toHaveBeenCalledTimes(1001);

await m.quit();
});
});

0 comments on commit fb5f154

Please sign in to comment.