Files
orca/cloud/apps/relay/src/postgres-idle-client-error.test.ts
T
Jinwoo Hong 3eec77c11a chore(cloud): add the relay fence broker, ops console, Terraform root, scripts, and 24 cloud-* workflows (#18413)
Phase 6 of the relay split: the relay's deploy/operate surface moves under cloud/ with 24 cloud-* workflows gated on ORCA_CLOUD_OPERATIONS_ENABLED, the Cloud SQL rollout lease action, the relay Terraform root (dual-accept identities for both repositories), scripts, docs, CODEOWNERS, and a terraform validate job in Cloud Verify.
2026-09-03 06:55:14 -04:00

23 lines
859 B
TypeScript

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', () => {
let listener: ((error: Error) => void) | undefined
const pool = {
on: vi.fn((_event: string, value: (error: Error) => void) => {
listener = value
return pool
})
}
const warning = vi.spyOn(console, 'warn').mockImplementation(() => {})
absorbPostgresIdleClientErrors(pool as never)
expect(() => listener?.(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')
warning.mockRestore()
})
})