From dae2990cbedc933cfc0572a13f461919e77c3a0c Mon Sep 17 00:00:00 2001 From: Wanjohi Date: Sat, 5 Sep 2026 18:07:41 +0300 Subject: [PATCH] docs(core): say which database the tests actually need MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The helper told you to use "an isolated database for tests", which reads as a database of its own and is not what the suite wants. Route tests reach the database through the app and core tests reach it directly, so two different values put the fixtures in one database and the assertions in the other — around forty failures, none of them in the code that caused it, and nothing in the output naming the setting. Also drops a type import nothing uses. --- packages/auth/src/issuer.ts | 1 - packages/core/src/db/test.ts | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/auth/src/issuer.ts b/packages/auth/src/issuer.ts index 0859b6b4..50f4348e 100644 --- a/packages/auth/src/issuer.ts +++ b/packages/auth/src/issuer.ts @@ -220,7 +220,6 @@ import { StorageRefreshStore } from './refresh.js'; import { - type DeviceGrant, type DeviceGrantSubject, type DeviceStore, hashDeviceCode, diff --git a/packages/core/src/db/test.ts b/packages/core/src/db/test.ts index 3baf8932..318a3e8f 100644 --- a/packages/core/src/db/test.ts +++ b/packages/core/src/db/test.ts @@ -3,11 +3,17 @@ import postgres from 'postgres'; /** * Fail-closed test database connection. * - * Tests must never silently fall back to an ad-hoc localhost database, so - * this throws unless an explicit `TEST_DATABASE_URL` is set. Use an isolated - * database for tests, e.g.: + * Tests must never silently fall back to an ad-hoc localhost database, so this + * throws unless an explicit `TEST_DATABASE_URL` is set. Use a database you do + * not mind losing, migrated fresh: * * TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/nestri + * + * **The same database `DATABASE_URL` names, not a second one.** Route tests + * reach the database through the app, which reads `DATABASE_URL`; core tests + * reach it through here. Two different values put the fixtures in one database + * and the assertions in the other, and the suite then fails in neither half's + * own code with nothing in the output naming the cause. */ export function testDb() { const url = process.env.TEST_DATABASE_URL;