fix: release() absichern, DATABASE_URL Startup-Check, execute-Test hinzugefügt

This commit is contained in:
2026-04-17 08:33:07 +00:00
parent c01befa477
commit 4f739f7b1e
3 changed files with 18 additions and 8 deletions

View File

@@ -53,13 +53,15 @@ describe('withTenant', () => {
).rejects.toThrow('Ungültige tenantId')
})
it('gibt dieselbe Client-Instanz an fn weiter (Connection-Isolation)', async () => {
let capturedClient: unknown
await withTenant('tenant1', async (client) => {
capturedClient = client
})
// Client muss nach withTenant released worden sein
it('released PoolClient nach Ausführung', async () => {
await withTenant('tenant1', async () => {})
expect(mockClient.release).toHaveBeenCalledOnce()
expect(capturedClient).toBeDefined()
})
it('execute delegiert an den dedizierten PoolClient', async () => {
await withTenant('abc123', async (client) => {
await client.execute('DELETE FROM sessions WHERE expired = true')
})
expect(mockClient.query).toHaveBeenCalledWith('DELETE FROM sessions WHERE expired = true')
})
})