feat(tests): integration suite harness against a real Postgres#55
Merged
Conversation
Adds tests/integration/ with a skipIf-gated suite. When DB_PASSWORD
is set AND sequelize.authenticate() succeeds, the tests run for
real against the live database. Otherwise they skip the entire
describe block — \`npm test\` keeps working in environments
without a Postgres reachable (CI without docker, local laptops
that haven't run \`docker compose up postgres\`, etc.).
What the harness covers in this first pass:
- sequelize.authenticate() succeeds
- Customer.findAll() returns an array against the real schema
- Customer create → findByPk → destroy round-trip
- Eager loading via the new include('company') association
(smoke test only — verifies the include doesn't throw, since
the real DB may legitimately be empty)
Each test cleans up its own rows by sentinel-string match
(\`_integ_<pid>_<timestamp>%\` LIKE) so a mid-test crash doesn't
poison subsequent runs. Tests share one connection (afterAll
closes it).
Out of scope here:
- End-to-end HTTP-through-router-to-real-DB. The current suite
proves the model layer; the next integration pass should add
supertest hitting the real router stack.
- testcontainers-style auto-managed PG container. Would be nice
but adds a devDep + docker-daemon dependency.
Verified locally: with DB_PASSWORD empty the suite reports
"29 passed | 1 skipped (30) / 223 passed | 4 skipped (227)" —
unit + API tests keep passing untouched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
CryptoJones
added a commit
that referenced
this pull request
May 18, 2026
After the harness in #55 landed, the actual flow to run integration tests against a live Postgres turned out to need three things the docs didn't mention: 1. docker-compose.override.yml that exposes 127.0.0.1:5432 to the host. The base docker-compose.yml deliberately keeps PG unreachable from the host for production hardening, but the vitest integration suite needs host-side TCP access. 2. \`docker compose down -v\` before re-running setup. The setup/TimeTracker.sql script does an unconditional \`CREATE SCHEMA dbo\` which fails (exit 3) against a populated postgres-data volume. Filed as a separate idempotency-fix tracker. 3. The exact env-var shape the integration suite reads (DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD). The override file is committed so contributors don't have to re-derive it. Production deployments should NOT use this override — port 5432 on a public host is a credential-brute-force invitation. The override's purpose and risk note are inline in the file's comment header. README gets a short "Testing" section pointing at tests/integration/README.md for the full flow. The integration README itself is rewritten end-to-end. Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CryptoJones
added a commit
that referenced
this pull request
May 18, 2026
Continues the docs-sync pattern from #44 and #53. CHANGELOG [Unreleased] now reflects: Added: - Sequelize associations (#54) - Integration test harness (#55) - Postman collection (#59) - TLS reverse-proxy compose (#60) - docker-compose.override.yml committed (#56) Fixed: - setup/TimeTracker.sql idempotency (#57) — removes the \`docker compose down -v\` workaround Docs: - Integration bring-up flow (#56, #58) - README sections for Testing and Behind TLS Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
tests/integration/— askipIf-gated suite that exercises real Sequelize against a live Postgres when one is reachable. WithoutDB_PASSWORDset or with the DB unreachable, the entire suite skips and the existing unit + API tests stay green.Coverage in this first pass:
sequelize.authenticate()findAllinclude({as: 'company'})associationCleanup: rows are tagged with a
_integ_<pid>_<timestamp>sentinel;afterAlldeletes by LIKE so a crashed run doesn't poison the table.Out of scope: end-to-end HTTP→router→real-DB via supertest, and testcontainers-managed Postgres. Those are natural next passes once this harness is in.
Test plan
DB_PASSWORDunset: vitest reports 29 passed / 1 skipped (this suite), 223 passed / 4 skipped (tests). The 4 skipped are the integration tests, intentionally.See
tests/integration/README.mdfor the bring-up flow.Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/