mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 17:47:40 +00:00
* test: replace redundant checks with observed behavior * docs: reconcile completed audit batches and upstream review --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
20 lines
775 B
TypeScript
20 lines
775 B
TypeScript
import pg from 'pg'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { absorbPostgresIdleClientErrors } from './database.js'
|
|
|
|
describe('PostgreSQL idle-client failure handling', () => {
|
|
it('absorbs the pool error without logging connection details', async () => {
|
|
const pool = new pg.Pool()
|
|
const warning = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
try {
|
|
absorbPostgresIdleClientErrors(pool)
|
|
expect(() => pool.emit('error', new Error('postgres://user:secret@database'))).not.toThrow()
|
|
expect(warning).toHaveBeenCalledWith('[orca-relay] idle PostgreSQL client failed')
|
|
expect(JSON.stringify(warning.mock.calls)).not.toContain('secret')
|
|
} finally {
|
|
warning.mockRestore()
|
|
await pool.end()
|
|
}
|
|
})
|
|
})
|