From 94a6b436f535eea2f741e3bd62117fd69a8e2cfc Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Thu, 13 Aug 2026 17:38:28 +0530 Subject: [PATCH] test(examples): give each run its own sqlite database The test profile pointed at ./test.db in the app directory, so a run inherited whatever schema an earlier run left behind. On a machine with a stale file, 0003_add_password re-applied ALTER TABLE ADD COLUMN over a column that already existed; fail-on-test-warnings turned the warning into a failure, and check:production failed for environment reasons rather than code. Each run now uses a fresh database under the OS temp directory. Verified by restoring the stale dev.db and test.db that reproduced the failure: the suite passes with them present. Co-Authored-By: Claude Opus 5 --- examples/basic-app/wrnexus.config.ts | 12 +++++++++++- .../apps/admin/wrnexus.config.ts | 9 ++++++++- .../apps/web/wrnexus.config.ts | 9 ++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/examples/basic-app/wrnexus.config.ts b/examples/basic-app/wrnexus.config.ts index f2cb88eb..cbb94a80 100644 --- a/examples/basic-app/wrnexus.config.ts +++ b/examples/basic-app/wrnexus.config.ts @@ -1,3 +1,6 @@ +import { tmpdir } from "node:os"; +import { join } from "node:path"; + import type { AppConfig } from "@wrnexus/styles"; /** @@ -100,7 +103,14 @@ const config: AppConfig = { seo: { title: "WrNexus (UAT)", robots: "noindex,nofollow" }, }, test: { - db: { driver: "sqlite", url: "file:./test.db" }, + // A fresh database per run. A file checked into the working tree would + // carry a schema from an earlier run, and a migration such as + // 0003_add_password then re-applies against a column that already + // exists, failing the suite on developer machines but not on CI. + db: { + driver: "sqlite", + url: `file:${join(tmpdir(), `wrnexus-test-${process.pid}.db`)}`, + }, }, }, }; diff --git a/examples/inter-app-api-showcase/apps/admin/wrnexus.config.ts b/examples/inter-app-api-showcase/apps/admin/wrnexus.config.ts index 3508cb54..315abed6 100644 --- a/examples/inter-app-api-showcase/apps/admin/wrnexus.config.ts +++ b/examples/inter-app-api-showcase/apps/admin/wrnexus.config.ts @@ -1,3 +1,6 @@ +import { tmpdir } from "node:os"; +import { join } from "node:path"; + import type { AppConfig } from "@wrnexus/styles"; const config: AppConfig = { @@ -133,7 +136,11 @@ const config: AppConfig = { profiles: { development: {}, test: { - db: { driver: "sqlite", url: "file:./test.db" }, + // A fresh database per run; a persisted file carries an earlier schema. + db: { + driver: "sqlite", + url: `file:${join(tmpdir(), `wrnexus-test-${process.pid}.db`)}`, + }, observability: { exporter: "none", sampleRate: 0 }, }, staging: { diff --git a/examples/inter-app-api-showcase/apps/web/wrnexus.config.ts b/examples/inter-app-api-showcase/apps/web/wrnexus.config.ts index 3172c1d1..facc82aa 100644 --- a/examples/inter-app-api-showcase/apps/web/wrnexus.config.ts +++ b/examples/inter-app-api-showcase/apps/web/wrnexus.config.ts @@ -1,3 +1,6 @@ +import { tmpdir } from "node:os"; +import { join } from "node:path"; + import type { AppConfig } from "@wrnexus/styles"; const config: AppConfig = { @@ -133,7 +136,11 @@ const config: AppConfig = { profiles: { development: {}, test: { - db: { driver: "sqlite", url: "file:./test.db" }, + // A fresh database per run; a persisted file carries an earlier schema. + db: { + driver: "sqlite", + url: `file:${join(tmpdir(), `wrnexus-test-${process.pid}.db`)}`, + }, observability: { exporter: "none", sampleRate: 0 }, }, staging: {