mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-12 22:13:05 +00:00
pnpm worktree next [--go] [--no-migrate] agora provisiona um ambiente determinístico por worktree: slot = parte numérica do código da Issue (C15→15; hash sem dígitos; bump em colisão entre worktrees vivos), dev server em 3100+slot, bancos teqo_wt<slot> / teqo_wt<slot>_test no container compartilhado (-p teqo) com a cadeia de migrations aplicada; escreve .env.local + .env.test.local (gitignored, marcador gerado; envs manuais nunca sobrescritos) e copia PAYLOAD_SECRET/Blob/VAPID do main. kill remove o worktree e dropa os bancos gerados (WITH FORCE, best-effort). Suites leem .env.test.local depois de .env.test (vitest.setup / playwright / db-doctor / gate-ci espelham o layering) e assertTestDatabase aceita teqo_test ou teqo_<worktree>_test em localhost só (fail-closed preservado). db:start/db:stop fixam -p teqo (um container de qualquer diretório); max_connections 200→400. Sem Docker (Cursor Cloud): degrada ao compartilhado com aviso. Derivação pura em scripts/lib/worktree-env.mjs (unit-tested); fluxo validado end-to-end: provision → migrate → 598/598 int no banco do worktree → kill sem resíduo.
19 lines
916 B
TypeScript
19 lines
916 B
TypeScript
// Load the isolated test environment — NEVER .env / .env.local, which point at
|
|
// the production database. `override: true` guarantees the test database wins
|
|
// even if a prod DATABASE_URL is already exported in the shell.
|
|
import { config as loadEnv } from 'dotenv'
|
|
|
|
import { assertTestDatabase } from './tests/helpers/assertTestDatabase'
|
|
|
|
loadEnv({ path: '.env.test', override: true })
|
|
// Per-worktree isolation: `.env.test.local` (gitignored, written by
|
|
// `pnpm worktree next`) wins over the committed `.env.test` when present.
|
|
loadEnv({ path: '.env.test.local', override: true })
|
|
|
|
// Optional local override when the default Docker port is occupied (e.g. mapped to 5433).
|
|
if (process.env.TEQO_TEST_DATABASE_URL) {
|
|
process.env.DATABASE_URL = process.env.TEQO_TEST_DATABASE_URL
|
|
}
|
|
|
|
// Fail closed: refuse to run the (destructive) suite against a non-test database.
|
|
assertTestDatabase(process.env.DATABASE_URL)
|