test: sqlite on windows

This commit is contained in:
abeatrix
2026-03-25 23:01:42 -07:00
parent 5a89f73a7d
commit d8d5649b81
3 changed files with 13 additions and 2 deletions
@@ -12,8 +12,7 @@ describe("UnifiedSessionPersistenceService", () => {
afterEach(() => {
for (const store of stores.splice(0)) {
const db = (store as unknown as { db?: { close?: () => void } }).db;
db?.close?.();
store.close();
}
for (const dir of tempDirs.splice(0)) {
rmSync(dir, { recursive: true, force: true });
@@ -57,6 +57,11 @@ export class SqliteSessionStore implements SessionStore {
return db;
}
close(): void {
this.db?.close?.();
this.db = undefined;
}
run(sql: string, params: unknown[] = []): { changes?: number } {
return this.getRawDb()
.prepare(sql)
+7
View File
@@ -11,6 +11,7 @@ export type SqliteStatement = {
export type SqliteDb = {
prepare: (sql: string) => SqliteStatement;
exec: (sql: string) => void;
close?: () => void;
};
export function nowIso(): string {
@@ -38,10 +39,12 @@ export function asBool(value: unknown): boolean {
function wrapBunDb(db: {
query: (sql: string) => SqliteStatement;
exec: (sql: string) => void;
close?: () => void;
}): SqliteDb {
return {
prepare: (sql) => db.query(sql),
exec: (sql) => db.exec(sql),
close: () => db.close?.(),
};
}
@@ -52,6 +55,7 @@ function wrapNodeDb(db: {
all: (...params: unknown[]) => Record<string, unknown>[];
};
exec: (sql: string) => void;
close?: () => void;
}): SqliteDb {
return {
prepare: (sql) => {
@@ -63,6 +67,7 @@ function wrapNodeDb(db: {
};
},
exec: (sql) => db.exec(sql),
close: () => db.close?.(),
};
}
@@ -78,6 +83,7 @@ export function loadSqliteDb(filePath: string): SqliteDb {
) => {
query: (sql: string) => SqliteStatement;
exec: (sql: string) => void;
close?: () => void;
};
};
return wrapBunDb(new Database(filePath, { create: true }));
@@ -103,6 +109,7 @@ export function loadSqliteDb(filePath: string): SqliteDb {
all: (...params: unknown[]) => Record<string, unknown>[];
};
exec: (sql: string) => void;
close?: () => void;
};
};
process.emitWarning = originalEmit;