Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/helpers/memdb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Test helper: fresh in-memory database with the full Recall schema.
//
// Property-based suites create a database per generated case (dozens per
// test), so the file-backed setupTestDb harness is too heavy — this builds
// the same tables/indexes in memory in ~1ms. FTS virtual tables and triggers
// are omitted: the export/dedup logic under property test never touches them.
import { Database } from 'bun:sqlite';
import { CREATE_TABLES, CREATE_INDEXES, CREATE_VECTOR_TABLES } from '../../src/db/schema';

export function createMemoryDb(): Database {
const db = new Database(':memory:');
db.exec('PRAGMA foreign_keys = ON'); // matches production getDb()
db.exec(CREATE_TABLES);
db.exec(CREATE_INDEXES);
db.exec(CREATE_VECTOR_TABLES);
return db;
}
Loading
Loading