Skip to content

Run the integration suite in a throwaway schema and add CI - #6

Merged
rijnb merged 6 commits into
mainfrom
fix/db-test-schema-ci
Oct 18, 2026
Merged

rijnb merged 6 commits into
mainfrom
fix/db-test-schema-ci

Conversation

@rijnb

@rijnb rijnb commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Why

The Postgres integration suite ran DROP TABLE mapcode_request on whatever TEST_DB_URL named, so pointing it at a real database deleted the event log. Its tests also shared state, so a single test run with -t failed. And nothing ran the suite or typechecked the tests, so both drifted unnoticed.

What changed

  • The integration suite pins every connection to a random mapcode_test_* schema, checks current_schema() before any DDL, recreates that schema before each test and drops it at the end. Each test seeds its own rows.
  • npm run typecheck:test (new tsconfig.test.json) typechecks src and test. The 3 stale test stubs it caught are fixed.
  • .github/workflows/ci.yml runs npm ci, both typechecks and npm test with Node 22 against a postgres:16 service on every PR and push to main.

Scope

  • Beads mapcode-rest-service-ts-2ig.8 and mapcode-rest-service-ts-2ig.7.
  • Leaves the SQL-substring assertions in the schema and stats-query unit tests alone. Another PR changes the schema code in parallel.

Blast Radius

Test code, a new tsconfig, a new script and a new workflow. No runtime code changes. The new workflow will also run on every other open PR, so those pick up a required-looking check once this lands.

Verification

  • Sentinel row in public.mapcode_request: gone after one run of the old suite, still there after the new suite. A TEST_DB_URL with ?options=-c search_path=public makes the suite fail on the current_schema() check before any DDL.
  • All 8 integration tests pass alone with -t. On main, -t "filters by kind" fails with relation "mapcode_request" does not exist.
  • The workflow's commands in a node:22 container against Postgres 16: npm ci, both typechecks, 722/722 tests, exit 0.
  • The backfill test seeds geo rows that have a point, which the per-test reset had dropped. With lat IS NULL AND removed from ANON_BACKFILL_SQL it fails (expected [ { ts: 1000, anon: true }, ...] to deeply equal [ { ts: 1000, anon: false }, ...]); unmutated it passes. It also passes with an added status::int < 40 predicate.

🤖 Generated with Claude Code

@rijnb
rijnb force-pushed the fix/db-test-schema-ci branch from 1e19280 to 8f70ee0 Compare October 17, 2026 10:06
rijnb and others added 6 commits October 18, 2026 10:28
The suite dropped mapcode_request on whatever TEST_DB_URL named. It now
pins every connection to a random schema, verifies current_schema() before
any DDL, and recreates that schema before each test, so each test seeds its
own rows and passes on its own with -t.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
npm run typecheck covers src only, so test stubs drift from the contracts
they stand in for. typecheck:test checks both and fails today on 2 stale
test stubs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The replay query stub in api-recording lacked the country and anon
columns. The flatgeobuf override in boundary-service cast a ReadableStream
to Uint8Array for an argument no override reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs on pull requests and on pushes to main with Node 22: npm ci, both
typechecks, and npm test with TEST_DB_URL pointing at a postgres:16
service container, so the integration suite checks the SQL on every PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-test schema reset left the backfill test with no geo rows that
have a point, so dropping `lat IS NULL` from ANON_BACKFILL_SQL passed
the suite. Seed GEO_ENCODE and DECODE before the backfill and assert
they stay anon=false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
failingReplay returned the optional ServerDeps["replay"], so spreading it
into an override left every field optional.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rijnb
rijnb force-pushed the fix/db-test-schema-ci branch from 827cf5a to c46e77b Compare October 18, 2026 08:29
@rijnb
rijnb merged commit 1f39623 into main Oct 18, 2026
1 check passed
@rijnb
rijnb deleted the fix/db-test-schema-ci branch October 18, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant