test: add a real-Postgres harness for end-to-end suites in tests/ - #29
Open
TheGreatAxios wants to merge 9 commits into
Conversation
TheGreatAxios
commented
Sep 25, 2026
TheGreatAxios
left a comment
Contributor
Author
There was a problem hiding this comment.
Reviewed all seven commits over three review passes. The harness gets a fresh database per suite through the destructive-test gate and uses the real grant evaluator. The round trip, the 413/415 checks and the migration tests go through the mounted app on real Postgres. The counts test seeds 120 rows, so it really crosses a page boundary. Each deletion matches a case the route suite already covers, and the acceptance suite now runs in bun run test. No open findings.
TheGreatAxios
force-pushed
the
cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests
branch
2 times, most recently
from
September 25, 2026 23:57
449538e to
5dd69de
Compare
TheGreatAxios
force-pushed
the
cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests
branch
from
September 26, 2026 01:29
5dd69de to
e9c157f
Compare
Each suite gets its own throwaway database with Interchange's control plane and this package's migrations applied, and a createArtifactRoutes app mounted for a seeded tenant principal behind the platform's real grant evaluator. Creating and dropping those databases goes through the same destructive-test gate as the src suite. bun run test now runs tests/ alongside src/, and tsconfig includes tests/ in place of the scripts/ directory that no longer exists.
A file uploaded through the mounted app into a disk-backed ContentStore downloads byte-for-byte, at version 1 and again after a metadata-only revision creates version 2. Downloading the older version of a stored file is refused, since stored bytes are not versioned.
An oversize file answers 413 and a disallowed MIME type answers 415, and neither leaves an artifact behind.
The runner's contract is that applying it creates the artifacts schema and tables, and applying it again changes nothing. Those two checks move to tests/ on a fresh database. The rest restated DDL line by line (constraints, indexes, foreign-key targets) that the SQL file itself states.
The gate test exercised the test harness, not the package. Counts and preview are served by routes, and the route suite now covers the counts walk across more than one page, skipping other tenants and archived rows, so the direct unit tests were duplicates.
Version bump and history paging, the create size limits, the not-found answers for archived, skill-draft and cross-tenant rows, idempotent archive and the expectedVersion precondition are all asserted through the mounted routes in mount.test.ts. What stays covers logic no route reaches: find-by-title, find-or-version races, concurrent writers and archives, lineage and digest rules, and serialization.
The acceptance scenarios move to tests/ and run with the rest of the suite instead of behind a separate test:acceptance script and CI step. The reference host stops being its own package: the root tsconfig maps @corbits/artifacts to src/ so the example compiles and runs in place, and its stale Interchange wiring is updated to the 0.4.0 types. The built dist/ stays covered by CI's Node consumer smoke test.
A failed beforeAll left afterAll throwing on an undefined handle, which buried the real setup error under a second TypeError.
TheGreatAxios
force-pushed
the
cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests
branch
from
September 26, 2026 01:37
e9c157f to
9966d7b
Compare
TheGreatAxios
added this pull request to stack #32
September 26, 2026 01:57
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
tests/lib/db-harness.tscreates a freshartifact_<random>_testdatabase for each suite on theARTIFACT_DATABASE_URLserver. It applies Interchange'srunMigrationsand thenrunArtifactMigrations, and drops the database afterwards. The same destructive-test gate as thesrcsuite guards it.artifactAppmountscreateArtifactRoutesfor a seeded tenant principal, authorized by the realcreateRequireGrantover the database'sgranttable.bun run testrunssrc/andtests/.ContentStore(tests/lib/fs-content-store.ts).src/migrations.test.ts.destructive-tests-gate,countsandpreviewunit tests. A route test now covers the counts walk across more than one page.artifacts.test.tscases thatmount.test.tsalready covers through routes.tests/reference-host.test.tsand runs inbun run test. Thetest:acceptancescript and its CI steps are gone.tsconfigmaps@corbits/artifactstosrc/, and the example shares the test database URL helpers.@intx/hub-commonand@intx/hub-sessionsare now pinned devDependencies.?version=1returns 400.Verification
bun install --frozen-lockfile, typecheck cleanCloses CL-9324
Closes CL-9149
Closes CL-9154
Closes CL-9140
Closes CL-9133
Closes CL-9136
Closes CL-9145