fix: evitar usar currentDb en tests al obtener DB

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
main
brobert 1 month ago
parent dce88e3874
commit c1083b19d3

@ -36,6 +36,8 @@ export function getDb(): Database {
if (!testScope) testScope = new AsyncLocalStorage<Database>(); if (!testScope) testScope = new AsyncLocalStorage<Database>();
const scoped = testScope.getStore(); const scoped = testScope.getStore();
if (scoped) return scoped; if (scoped) return scoped;
// En tests, no hacer fallback al currentDb global para evitar fugas entre suites
throw new DbNotConfiguredError('Database has not been configured. Call setDb(db) before using getDb().');
} }
if (currentDb) return currentDb; if (currentDb) return currentDb;
throw new DbNotConfiguredError('Database has not been configured. Call setDb(db) before using getDb().'); throw new DbNotConfiguredError('Database has not been configured. Call setDb(db) before using getDb().');

Loading…
Cancel
Save