mirror of
https://github.com/cline/cline.git
synced 2026-09-21 05:10:09 +08:00
test: sqlite on windows
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user