refactor(tests): move backend tests into src/backend/tests mirror tree

Backend *.test.ts files (and the test-support harness) no longer sit next
to source files; they live under src/backend/tests/ mirroring the source
layout. Imports rewritten accordingly; CLAUDE.md convention updated.
This commit is contained in:
LukeGus
2026-07-16 04:31:29 -05:00
parent 8b6037b7ff
commit 7f43932429
89 changed files with 200 additions and 160 deletions
@@ -0,0 +1,31 @@
import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";
import * as schema from "../../../database/db/schema.js";
import type { DatabaseContext } from "../../../database/repositories/database-context.js";
export class TestSqliteDatabase {
private sqlite: Database.Database | null = null;
private context: DatabaseContext | null = null;
async connect(): Promise<DatabaseContext> {
if (this.context) return this.context;
this.sqlite = new Database(":memory:");
this.sqlite.exec("PRAGMA foreign_keys = ON");
this.context = {
dialect: "sqlite",
drizzle: drizzle(this.sqlite, { schema }),
sqlite: this.sqlite,
};
return this.context;
}
async close(): Promise<void> {
if (this.sqlite) {
this.sqlite.close();
this.sqlite = null;
this.context = null;
}
}
}