From acdb08091a555c9ee258182ddafbfb54d0ebc64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Arturo=20Cabral=20Mej=C3=ADa?= Date: Thu, 11 Jan 2024 20:34:44 -0500 Subject: [PATCH] chore: fix intg tests not closing --- test/integration/features/shared.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/integration/features/shared.ts b/test/integration/features/shared.ts index 2759b3f7..d515d00f 100644 --- a/test/integration/features/shared.ts +++ b/test/integration/features/shared.ts @@ -16,8 +16,10 @@ import Sinon from 'sinon' import { connect, createIdentity, createSubscription, sendEvent } from './helpers' import { getMasterDbClient, getReadReplicaDbClient } from '../../../src/database/client' import { AppWorker } from '../../../src/app/worker' +import { CacheClient } from '../../../src/@types/cache' import { DatabaseClient } from '../../../src/@types/base' import { Event } from '../../../src/@types/event' +import { getCacheClient } from '../../../src/cache/client' import { SettingsStatic } from '../../../src/utils/settings' import { workerFactory } from '../../../src/factories/worker-factory' @@ -27,6 +29,7 @@ let worker: AppWorker let dbClient: DatabaseClient let rrDbClient: DatabaseClient +let cacheClient: CacheClient export const streams = new WeakMap>() @@ -35,7 +38,9 @@ BeforeAll({ timeout: 1000 }, async function () { process.env.SECRET = Math.random().toString().repeat(6) dbClient = getMasterDbClient() rrDbClient = getReadReplicaDbClient() + cacheClient = getCacheClient() await dbClient.raw('SELECT 1=1') + await rrDbClient.raw('SELECT 1=1') Sinon.stub(SettingsStatic, 'watchSettings') const settings = SettingsStatic.createSettings() @@ -54,7 +59,11 @@ BeforeAll({ timeout: 1000 }, async function () { AfterAll(async function() { worker.close(async () => { - await Promise.all([dbClient.destroy(), rrDbClient.destroy()]) + await Promise.all([ + dbClient.destroy(), + rrDbClient.destroy(), + cacheClient.disconnect(), + ]) }) }) @@ -75,8 +84,6 @@ After(async function () { } this.parameters.clients = {} - const dbClient = getMasterDbClient() - await dbClient('events') .whereIn('event_pubkey', Object .values(this.parameters.identities as Record)