Skip to content

Commit ff82b29

Browse files
committed
Fix test tasks connecting to production DB
mise.toml's `_.file = ".env"` loads the production DATABASE_URL into the process environment before any task runs. Deno's --env-file flag does not override variables already present in the environment, so both `deno task test` and `mise run migrate:test` were silently connecting to the production database instead of the test database. This caused local tests to see real production data (e.g. posts from November 2025) and migrate:test to apply migrations against production rather than hackerspub_test. CI was also affected when DATABASE_URL was already set in the environment. Fix by using godotenv (github:joho/godotenv) with the -o (override) flag, which forcibly overwrites any pre-existing environment variable with the value from .env.test regardless of how it was set. Assisted-by: Claude Code:claude-sonnet-4-6
1 parent c3f5ef8 commit ff82b29

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
],
215215
"command": "deno fmt --check && deno lint && deno check ."
216216
},
217-
"test": "deno test --env-file=.env.test --allow-all --parallel",
217+
"test": "godotenv -f .env.test -o deno test --allow-all --parallel",
218218
"dev": "cd web && deno task dev",
219219
"build": "cd web && deno task build",
220220
"start": "cd web && deno task start",

mise.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ deno = "2.7.4"
33
node = "24"
44
pnpm = "10.12.4"
55
"npm:@sentry/mcp-server" = "latest"
6+
"github:joho/godotenv" = "latest"
67

78
[env]
89
_.file = ".env"
@@ -61,7 +62,7 @@ run = "deno run -A drizzle-kit generate"
6162

6263
[tasks."migrate:test"]
6364
description = "Run database migrations against the test database"
64-
run = "deno run --env-file=.env.test -A drizzle-kit migrate"
65+
run = "godotenv -f .env.test -o deno run -A drizzle-kit migrate"
6566

6667
[tasks."keygen"]
6768
description = "Generate an instance actor key pair (prints a JWK to stdout)"

0 commit comments

Comments
 (0)