Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt standard monorepo conventions (apps/ for runnable apps, packages/ for reusable libraries). Update all config files, shared package imports, test fixtures, and documentation to reflect new paths. Key fixes: - Update workspace config to ["apps/*", "packages/*"] - Update tsconfig.json rootDir/include for apps/server/ - Add apps/web/** to vitest exclude list - Update drizzle.config.ts schema path - Fix ensure-schema.ts migration path detection (3 levels up in dev, 2 levels up in dist) - Fix tests/integration/cli-server.test.ts import paths - Update packages/shared imports to apps/server/ paths - Update all docs/ files with new paths
31 lines
766 B
TypeScript
31 lines
766 B
TypeScript
/**
|
|
* Test helpers for repository tests.
|
|
*
|
|
* Provides utilities for setting up in-memory test databases
|
|
* with schema applied.
|
|
*/
|
|
|
|
import Database from 'better-sqlite3';
|
|
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
|
import type { DrizzleDatabase } from '../../index.js';
|
|
import { ensureSchema } from '../../ensure-schema.js';
|
|
import * as schema from '../../schema.js';
|
|
|
|
/**
|
|
* Create an in-memory test database with schema applied.
|
|
* Returns a fresh Drizzle instance for each call.
|
|
*/
|
|
export function createTestDatabase(): DrizzleDatabase {
|
|
const sqlite = new Database(':memory:');
|
|
|
|
// Enable foreign keys
|
|
sqlite.pragma('foreign_keys = ON');
|
|
|
|
const db = drizzle(sqlite, { schema });
|
|
|
|
// Create all tables
|
|
ensureSchema(db);
|
|
|
|
return db;
|
|
}
|