test: add deterministic task behaviour tests

This commit is contained in:
Mpho10111
2026-08-11 21:15:21 +02:00
parent 75797c8419
commit 67404c2de2
6 changed files with 204 additions and 1 deletions

View File

@@ -21,6 +21,12 @@ export function getDatabase() {
return globalDatabase.plannerDatabase;
}
if (globalDatabase.plannerDatabase) {
globalDatabase.plannerDatabase.close();
delete globalDatabase.plannerDatabase;
delete globalDatabase.plannerDatabasePath;
}
fs.mkdirSync(path.dirname(databasePath), { recursive: true });
const database = new DatabaseSync(databasePath);
@@ -34,3 +40,13 @@ export function getDatabase() {
return database;
}
export function closeDatabaseForTests() {
const globalDatabase = globalThis as DatabaseGlobal;
if (globalDatabase.plannerDatabase) {
globalDatabase.plannerDatabase.close();
delete globalDatabase.plannerDatabase;
delete globalDatabase.plannerDatabasePath;
}
}