19 lines
1.1 KiB
TypeScript
19 lines
1.1 KiB
TypeScript
import { createHash } from 'node:crypto';
|
|
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const sql = readFileSync(new URL('../../server/postgres/migrations/027_regulatory_mapping_batches.sql', import.meta.url), 'utf8');
|
|
|
|
describe('regulatory mapping batch persistence schema', () => {
|
|
it('keeps orchestration project-scoped and protects idempotency and active scope', () => {
|
|
expect(createHash('sha256').update(sql, 'utf8').digest('hex')).toBe('d89055c3e723b09d8d8be7f4225bfd08442f0d66e4e0b4ea3aa62ae6209e9ee9');
|
|
expect(sql).toContain('CREATE TABLE assessor_regulatory_mapping_batches');
|
|
expect(sql).toContain('project_id text NOT NULL REFERENCES assessor_projects(id) ON DELETE CASCADE');
|
|
expect(sql).toContain('filter_hash text NOT NULL');
|
|
expect(sql).toContain('UNIQUE (project_id, idempotency_key)');
|
|
expect(sql).toMatch(/UNIQUE INDEX assessor_regulatory_mapping_batches_active_scope_uq[\s\S]*WHERE run_status IN \('queued', 'running'\)/);
|
|
expect(sql).toContain('(project_id, scope_key, created_at DESC, id DESC)');
|
|
expect(sql).not.toContain('source_result_id');
|
|
});
|
|
});
|