fix: permitir fallback a currentDb en tests cuando no hay scope

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

@ -36,7 +36,8 @@ export function getDb(): Database {
if (!testScope) testScope = new AsyncLocalStorage<Database>();
const scoped = testScope.getStore();
if (scoped) return scoped;
// En tests, no hacer fallback al currentDb global para evitar fugas entre suites
// En tests, permitir fallback a currentDb si está configurada explícitamente en el hook
if (currentDb) return currentDb;
throw new DbNotConfiguredError('Database has not been configured. Call setDb(db) before using getDb().');
}
if (currentDb) return currentDb;

Loading…
Cancel
Save