mirror of
https://github.com/Cameri/nostream.git
synced 2025-09-17 19:13:35 +02:00
chore: fix intg tests not closing
This commit is contained in:
@@ -16,8 +16,10 @@ import Sinon from 'sinon'
|
|||||||
import { connect, createIdentity, createSubscription, sendEvent } from './helpers'
|
import { connect, createIdentity, createSubscription, sendEvent } from './helpers'
|
||||||
import { getMasterDbClient, getReadReplicaDbClient } from '../../../src/database/client'
|
import { getMasterDbClient, getReadReplicaDbClient } from '../../../src/database/client'
|
||||||
import { AppWorker } from '../../../src/app/worker'
|
import { AppWorker } from '../../../src/app/worker'
|
||||||
|
import { CacheClient } from '../../../src/@types/cache'
|
||||||
import { DatabaseClient } from '../../../src/@types/base'
|
import { DatabaseClient } from '../../../src/@types/base'
|
||||||
import { Event } from '../../../src/@types/event'
|
import { Event } from '../../../src/@types/event'
|
||||||
|
import { getCacheClient } from '../../../src/cache/client'
|
||||||
import { SettingsStatic } from '../../../src/utils/settings'
|
import { SettingsStatic } from '../../../src/utils/settings'
|
||||||
import { workerFactory } from '../../../src/factories/worker-factory'
|
import { workerFactory } from '../../../src/factories/worker-factory'
|
||||||
|
|
||||||
@@ -27,6 +29,7 @@ let worker: AppWorker
|
|||||||
|
|
||||||
let dbClient: DatabaseClient
|
let dbClient: DatabaseClient
|
||||||
let rrDbClient: DatabaseClient
|
let rrDbClient: DatabaseClient
|
||||||
|
let cacheClient: CacheClient
|
||||||
|
|
||||||
export const streams = new WeakMap<WebSocket, Observable<unknown>>()
|
export const streams = new WeakMap<WebSocket, Observable<unknown>>()
|
||||||
|
|
||||||
@@ -35,7 +38,9 @@ BeforeAll({ timeout: 1000 }, async function () {
|
|||||||
process.env.SECRET = Math.random().toString().repeat(6)
|
process.env.SECRET = Math.random().toString().repeat(6)
|
||||||
dbClient = getMasterDbClient()
|
dbClient = getMasterDbClient()
|
||||||
rrDbClient = getReadReplicaDbClient()
|
rrDbClient = getReadReplicaDbClient()
|
||||||
|
cacheClient = getCacheClient()
|
||||||
await dbClient.raw('SELECT 1=1')
|
await dbClient.raw('SELECT 1=1')
|
||||||
|
await rrDbClient.raw('SELECT 1=1')
|
||||||
Sinon.stub(SettingsStatic, 'watchSettings')
|
Sinon.stub(SettingsStatic, 'watchSettings')
|
||||||
const settings = SettingsStatic.createSettings()
|
const settings = SettingsStatic.createSettings()
|
||||||
|
|
||||||
@@ -54,7 +59,11 @@ BeforeAll({ timeout: 1000 }, async function () {
|
|||||||
|
|
||||||
AfterAll(async function() {
|
AfterAll(async function() {
|
||||||
worker.close(async () => {
|
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 = {}
|
this.parameters.clients = {}
|
||||||
|
|
||||||
const dbClient = getMasterDbClient()
|
|
||||||
|
|
||||||
await dbClient('events')
|
await dbClient('events')
|
||||||
.whereIn('event_pubkey', Object
|
.whereIn('event_pubkey', Object
|
||||||
.values(this.parameters.identities as Record<string, { pubkey: string }>)
|
.values(this.parameters.identities as Record<string, { pubkey: string }>)
|
||||||
|
Reference in New Issue
Block a user