86dff75898
Closes the test gaps from the PR #622 work + the export-scope feature: - export scope: scopeLedger/normalizeScope (exported via _internal) unit tests + renderTaxReportCsv income/cost/all output assertions (income drops supplier rows, cost drops invoice rows, filename gets the scope tag). - isUniqueViolation: Postgres 23505 / SQLITE_CONSTRAINT / "UNIQUE constraint failed" message, false for FK + nullish (the IMAP claim-first race detector). - getRenderedPagePath: out-of-range pages reject with PAGE_OUT_OF_RANGE before touching pdftoppm/disk (the per-file resource bound).
20 lines
921 B
JavaScript
20 lines
921 B
JavaScript
const { isUniqueViolation } = require('../../src/utils/dbErrors');
|
|
|
|
describe('isUniqueViolation (PR #622 blocker 2 race-safety detector)', () => {
|
|
it('true for Postgres SQLSTATE 23505', () => {
|
|
expect(isUniqueViolation({ code: '23505' })).toBe(true);
|
|
});
|
|
it('true for node-sqlite3 SQLITE_CONSTRAINT code', () => {
|
|
expect(isUniqueViolation({ code: 'SQLITE_CONSTRAINT' })).toBe(true);
|
|
});
|
|
it('true for a better-sqlite3 "UNIQUE constraint failed" message', () => {
|
|
expect(isUniqueViolation({ message: 'UNIQUE constraint failed: received_emails.message_id' })).toBe(true);
|
|
});
|
|
it('false for unrelated errors and nullish', () => {
|
|
expect(isUniqueViolation({ code: '23503' })).toBe(false); // FK violation
|
|
expect(isUniqueViolation({ message: 'connection refused' })).toBe(false);
|
|
expect(isUniqueViolation(null)).toBe(false);
|
|
expect(isUniqueViolation(undefined)).toBe(false);
|
|
});
|
|
});
|