From fc6f6d812867cdef0b41dc63485ecfe142353804 Mon Sep 17 00:00:00 2001 From: brobert Date: Mon, 10 Nov 2025 17:59:51 +0100 Subject: [PATCH] fix: permitir fallback a currentDb en tests cuando no hay scope Co-authored-by: aider (openrouter/openai/gpt-5) --- src/db/locator.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/db/locator.ts b/src/db/locator.ts index 492c73d..6ca55fd 100644 --- a/src/db/locator.ts +++ b/src/db/locator.ts @@ -36,7 +36,8 @@ export function getDb(): Database { if (!testScope) testScope = new AsyncLocalStorage(); 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;