Skip to content

Commit

Permalink
fixup! add connection pool manager and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
despairblue committed Dec 23, 2024
1 parent 9b9595c commit 7e86426
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions packages/nodes-base/utils/__tests__/connection-pool-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ import { ConnectionPoolManager } from '@utils/connection-pool-manager';
const ttl = 5 * 60 * 1000;
const cleanUpInterval = 60 * 1000;

let cpm: ConnectionPoolManager;

beforeAll(() => {
jest.useFakeTimers();
cpm = ConnectionPoolManager.getInstance();
});

beforeEach(async () => {
await cpm.purgeConnections();
});

afterAll(() => {
cpm.onShutdown();
});

test('getInstance returns a singleton', () => {
Expand All @@ -15,16 +26,6 @@ test('getInstance returns a singleton', () => {
});

describe('getConnection', () => {
let cpm: ConnectionPoolManager;

beforeAll(() => {
cpm = ConnectionPoolManager.getInstance();
});

beforeEach(async () => {
await cpm.purgeConnections();
});

test('calls fallBackHandler only once and returns the first value', async () => {
// ARRANGE
const connectionType = {};
Expand Down Expand Up @@ -105,16 +106,6 @@ describe('getConnection', () => {
});

describe('onShutdown', () => {
let cpm: ConnectionPoolManager;

beforeAll(() => {
cpm = ConnectionPoolManager.getInstance();
});

beforeEach(async () => {
await cpm.purgeConnections();
});

test('calls all clean up handlers', async () => {
// ARRANGE
const connectionType1 = {};
Expand Down

0 comments on commit 7e86426

Please sign in to comment.