/** * Regression test: EvidenceStore SQLite persistence * * Verifies that EvidenceStore uses SQLite (bun:sqlite) instead of * in-memory Map for persistent storage. */ import { describe, test, expect } from 'bun:test' import { readFileSync } from 'fs' import { join } from 'path' const SOURCE_PATH = join( import.meta.dir, '..', '..', 'src', 'artifacts', 'EvidenceStore.ts' ) const source = readFileSync(SOURCE_PATH, 'utf-8') describe('EvidenceStore SQLite persistence', () => { test('EvidenceStore does not use in-memory Map', () => { // Should not have Map< for storage expect(source).not.toMatch(/evidenceStore:\s*Map { // Constructor should accept a Database parameter expect(source).toContain('db: Database') // Should import Database from bun:sqlite expect(source).toContain("from 'bun:sqlite'") }) test('EvidenceStore has initSchema method', () => { expect(source).toContain('initSchema()') // Should be called in constructor expect(source).toContain('this.initSchema()') }) test('EvidenceStore creates evidence_refs table', () => { expect(source).toContain('CREATE TABLE IF NOT EXISTS evidence_refs') // Should have key columns expect(source).toContain('evidence_ref_id TEXT PRIMARY KEY') expect(source).toContain('session_id TEXT NOT NULL') expect(source).toContain('kind TEXT NOT NULL') }) test('EvidenceStore uses INSERT INTO for create', () => { expect(source).toContain('INSERT INTO evidence_refs') }) test('EvidenceStore applies WAL PRAGMA', () => { expect(source).toContain('PRAGMA journal_mode = WAL') }) })