← back to Costa Rica
costa-rica: make the test suite env-independent — load dotenv in booking-pay-idempotency (Cody cycle-17 follow-up) — TK-10346
2263da5a701bcd994068097b882fe2a5e7f2e7fc · 2026-09-24 00:40:05 -0700 · Steve
booking-pay-idempotency.test.js is a REAL-DB integration test (requires ../lib/db,
which builds the pg pool from process.env.DATABASE_URL at load) but — unlike its
siblings payouts/host-listing-race/double-book/server-routes — never called
require('dotenv').config(). So a bare `node --test test/*.test.js` or a fresh CI
runner with no exported DATABASE_URL failed its 4 tests with
`database "macstudio3" does not exist` (pg falling back to the OS-username DB) — a
false red that only passed because the prior session had DATABASE_URL exported.
Fix: added `require('dotenv').config()` at the top (before the lib/db require),
matching payouts.test.js's existing convention. It was the only real-DB test file
using the real pool that lacked the line (the other DATABASE_URL-lacking test files
mock pool.query, so they never connect).
Verified: `unset DATABASE_URL; node --test test/*.test.js` -> 190/190 (was 186/190),
and `npm test` -> 190/190. Safe: .env has NO provider creds (only DATABASE_URL /
BASIC_AUTH / PG* / SITE_*), so loading dotenv can't flip any payment adapter to live
mode; and no test relies on DATABASE_URL being absent.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TouFkmUGKHtwqpZwgReVic
Files touched
M test/booking-pay-idempotency.test.js
Diff
commit 2263da5a701bcd994068097b882fe2a5e7f2e7fc
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Sep 24 00:40:05 2026 -0700
costa-rica: make the test suite env-independent — load dotenv in booking-pay-idempotency (Cody cycle-17 follow-up) — TK-10346
booking-pay-idempotency.test.js is a REAL-DB integration test (requires ../lib/db,
which builds the pg pool from process.env.DATABASE_URL at load) but — unlike its
siblings payouts/host-listing-race/double-book/server-routes — never called
require('dotenv').config(). So a bare `node --test test/*.test.js` or a fresh CI
runner with no exported DATABASE_URL failed its 4 tests with
`database "macstudio3" does not exist` (pg falling back to the OS-username DB) — a
false red that only passed because the prior session had DATABASE_URL exported.
Fix: added `require('dotenv').config()` at the top (before the lib/db require),
matching payouts.test.js's existing convention. It was the only real-DB test file
using the real pool that lacked the line (the other DATABASE_URL-lacking test files
mock pool.query, so they never connect).
Verified: `unset DATABASE_URL; node --test test/*.test.js` -> 190/190 (was 186/190),
and `npm test` -> 190/190. Safe: .env has NO provider creds (only DATABASE_URL /
BASIC_AUTH / PG* / SITE_*), so loading dotenv can't flip any payment adapter to live
mode; and no test relies on DATABASE_URL being absent.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TouFkmUGKHtwqpZwgReVic
---
test/booking-pay-idempotency.test.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/booking-pay-idempotency.test.js b/test/booking-pay-idempotency.test.js
index 54a36bf..9618af9 100644
--- a/test/booking-pay-idempotency.test.js
+++ b/test/booking-pay-idempotency.test.js
@@ -5,6 +5,7 @@
// Covers Cody gate findings #1/#2.
// Integration test using the REAL dev DB; cleans up after itself.
+require('dotenv').config(); // load DATABASE_URL before lib/db builds the pool (env-independent suite)
const { test, after } = require('node:test');
const assert = require('node:assert');
const { pool } = require('../lib/db');
← cb24e9d cycle 17 docs: YOLO_NOTES ledger — pool consolidation + expl
·
back to Costa Rica
·
cycle 18 docs: YOLO_NOTES ledger — env-independent test suit f326dd4 →