chore(quick-260613-ndv-02): clean-slate comment in setup.ts + README local-test docs
- Update apps/api/test/setup.ts header: clarify tests run against familysync_test
(provisioned by global-setup.ts), document users-cleanup decision (intact across
tests), and note CI-vs-local env difference
- Add apps/api/README.md "Running API tests locally" section: documents the test
DB isolation, run command, DB_ROOT_PASSWORD requirement, and CI no-op behaviour
- Fix apps/api/test/global-setup.ts: switch from drizzle({ client, mode }) to
drizzle(pool, { mode }) — drizzle-orm@0.45.2 isConfig() has a tautological OR
in the `mode` branch that always returns false, causing the combined-config form
to pass the config object as the client (client.query is not a function); two-arg
form routes correctly; 244/244 tests pass against familysync_test
This commit is contained in:
@@ -144,6 +144,26 @@ pnpm --filter @familysync/api typecheck
|
||||
|
||||
Integration tests that hit MariaDB require a running dev DB with `DB_HOST=127.0.0.1` and credentials from your `.env`. See [../../docs/TESTING.md](../../docs/TESTING.md) for the full setup.
|
||||
|
||||
## Running API tests locally
|
||||
|
||||
Local test runs use a dedicated `familysync_test` database so the dev `familysync` database is never mutated. `test/global-setup.ts` creates and migrates `familysync_test` automatically on the first run.
|
||||
|
||||
**Prerequisites:**
|
||||
|
||||
- Dev MariaDB running and port-bound (`127.0.0.1:3306`) — start with `docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d mariadb`
|
||||
- `.env` sourced in your shell (provides `DB_PASSWORD`, `DB_ROOT_PASSWORD`, and other credentials)
|
||||
|
||||
**Run command:**
|
||||
|
||||
```bash
|
||||
set -a; source .env; set +a
|
||||
DB_HOST=127.0.0.1 pnpm --filter @familysync/api test
|
||||
```
|
||||
|
||||
`DB_ROOT_PASSWORD` must be set in `.env` for the one-time `CREATE DATABASE` / `GRANT` that provisions `familysync_test`. Subsequent runs skip the provisioning step if the database already exists (`CREATE DATABASE IF NOT EXISTS`).
|
||||
|
||||
**CI is unaffected.** `test/global-setup.ts` returns immediately when `CI` is set (the CI `api` job provisions its own `familysync` service DB and runs `db:migrate` before the test step). The `test.env` DB override in `vitest.config.ts` is also a no-op under CI.
|
||||
|
||||
## Further reading
|
||||
|
||||
- [Architecture](../../docs/ARCHITECTURE.md) — system overview and component diagram
|
||||
|
||||
Reference in New Issue
Block a user