mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 18:04:18 +00:00
test(server): seed the session, lease and rollback specs through the factories
The specs written alongside the session, transaction and lifecycle work still seeded and read with raw statements. They go through the ORM factories now; the few that test SQL below the ORM carry a test-sql-allow reason. The raw SQL baseline holds 177 statements in 6 files.
This commit is contained in:
@@ -38,6 +38,7 @@ function portWith(maintenance: { walCheckpoint: unknown; vacuumInto: unknown }):
|
||||
function writeDb(file: string, label: string): void {
|
||||
const db = new Database(file);
|
||||
db.exec('CREATE TABLE marker (label TEXT NOT NULL)');
|
||||
// test-sql-allow: the marker table is a bare fixture file no entity maps, and no ORM is bound to this handle.
|
||||
db.prepare('INSERT INTO marker (label) VALUES (?)').run(label);
|
||||
db.close();
|
||||
}
|
||||
@@ -45,6 +46,7 @@ function writeDb(file: string, label: string): void {
|
||||
function readLabel(file: string): string {
|
||||
const db = new Database(file, { readonly: true });
|
||||
try {
|
||||
// test-sql-allow: reads the copied file on a read-only handle no ORM is bound to, from a table no entity maps.
|
||||
return (db.prepare('SELECT label FROM marker').get() as { label: string }).label;
|
||||
} finally {
|
||||
db.close();
|
||||
@@ -102,6 +104,7 @@ describe('SqliteDatabaseBackup', () => {
|
||||
|
||||
it('SQLBK-004: writes a consistent copy of the live database', async () => {
|
||||
// A write that sits in the WAL only: VACUUM INTO still carries it.
|
||||
// test-sql-allow: the marker table is a bare fixture no entity maps; the write has to land in the WAL of this file.
|
||||
live.prepare('UPDATE marker SET label = ?').run('after');
|
||||
const target = path.join(dir, 'copy.db');
|
||||
const port = portWith(new MaintenanceRepository(orm.em));
|
||||
|
||||
Reference in New Issue
Block a user