Skip to content

Commit

Permalink
chore: fix intg tests not closing
Browse files Browse the repository at this point in the history
  • Loading branch information
cameri committed Jan 12, 2024
1 parent d9e4020 commit acdb080
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/integration/features/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -27,6 +29,7 @@ let worker: AppWorker

let dbClient: DatabaseClient
let rrDbClient: DatabaseClient
let cacheClient: CacheClient

export const streams = new WeakMap<WebSocket, Observable<unknown>>()

Expand All @@ -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()

Expand All @@ -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(),
])
})
})

Expand All @@ -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<string, { pubkey: string }>)
Expand Down

0 comments on commit acdb080

Please sign in to comment.