Files
orca/cloud/apps/relay/src/postgres-idle-client-error.test.ts
T
OrcaWinandOrcaWin 8f6283b32b test: exercise real boundaries and trim redundant cases (#32353)
* 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>
2026-10-23 04:32:31 -07:00

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()
}
})
})