- Add tsconfig.test.json + typecheck:test script so test/ is type-checked; fixes real type errors it surfaced (hashedPw typing, PartialUser|ClientUser narrowing for .email). - Add HTTP-level auth-http.test.ts for the api backend covering login/session-cookie/logout/clear-sessions/bearer-apikey flows, since ApiInterface doesn't implement the session/login methods needed to run the shared session/auth suites directly. - Make the readonly-db test in shared/users.ts actually construct a readonly db instance (previously a no-op that never ran) via a new getReadonlyDb parameter, wired up for both sqlite and api backends. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
25 lines
906 B
TypeScript
25 lines
906 B
TypeScript
import { getWrappedDb } from "../../src/db/sqlite/impl/index.js";
|
|
import { SqliteMigrator } from "../../src/db/sqlite/SqliteMigrator.js";
|
|
import { SqliteInterface } from "../../src/db/sqlite/SqliteInterface.js";
|
|
import type { WrappedDb } from "../../src/db/sqlite/impl/types.js";
|
|
|
|
export interface TestDb {
|
|
db: SqliteInterface;
|
|
wrapped: WrappedDb;
|
|
close(): void;
|
|
}
|
|
|
|
export async function createTestDb(): Promise<TestDb> {
|
|
const wrapped = getWrappedDb("node", ":memory:", {});
|
|
const migrator = new SqliteMigrator(wrapped);
|
|
await migrator.migrateTo(3);
|
|
const db = new SqliteInterface(wrapped);
|
|
return { db, wrapped, close: () => wrapped.destroy() };
|
|
}
|
|
|
|
export async function createReadonlyTestDb(): Promise<TestDb> {
|
|
const wrapped = getWrappedDb("node", ":memory:", { readonly: true });
|
|
const db = new SqliteInterface(wrapped);
|
|
return { db, wrapped, close: () => wrapped.destroy() };
|
|
}
|