Skip to content

Commit

Permalink
tests: Cleanup redis pool properly in tests (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcw- authored Feb 29, 2020
1 parent 3fe55ea commit 6c8b6b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class QueryOrchestrator {
throw new Error(`Only 'redis' or 'memory' are supported for cacheAndQueueDriver option`);
}

this.redisPool = redisPool;
this.queryCache = new QueryCache(
this.redisPrefix, this.driverFactory, this.logger, {
externalDriverFactory,
Expand Down Expand Up @@ -87,6 +88,10 @@ class QueryOrchestrator {
resultFromCacheIfExists(queryBody) {
return this.queryCache.resultFromCacheIfExists(queryBody);
}

async cleanup() {
await this.redisPool.cleanup();
}
}

module.exports = QueryOrchestrator;
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ class MockDriver {

describe('QueryOrchestrator', () => {
let mockDriver = null;
const queryOrchestrator = new QueryOrchestrator(
'TEST', async () => mockDriver, (msg, params) => console.log(msg, params)
);

beforeAll(() => {
mockDriver = new MockDriver();
});

const queryOrchestrator = new QueryOrchestrator(
'TEST', async () => mockDriver, (msg, params) => console.log(msg, params)
);
afterAll(async () => {
await queryOrchestrator.cleanup();
});

test('basic', async () => {
const query = {
Expand Down

0 comments on commit 6c8b6b3

Please sign in to comment.