Skip to content

test: add a real-Postgres harness for end-to-end suites in tests/ - #29

Open
TheGreatAxios wants to merge 9 commits into
cl-9053-artifacts-replace-mountartifacts-withfrom
cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests
Open

TheGreatAxios wants to merge 9 commits into
cl-9053-artifacts-replace-mountartifacts-withfrom
cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • tests/lib/db-harness.ts creates a fresh artifact_<random>_test database for each suite on the ARTIFACT_DATABASE_URL server. It applies Interchange's runMigrations and then runArtifactMigrations, and drops the database afterwards. The same destructive-test gate as the src suite guards it. artifactApp mounts createArtifactRoutes for a seeded tenant principal, authorized by the real createRequireGrant over the database's grant table. bun run test runs src/ and tests/.
  • New e2e suites:
    • An upload, revise and download round trip on a filesystem ContentStore (tests/lib/fs-content-store.ts).
    • Upload policy: an oversize file gets 413, a disallowed MIME type gets 415, and neither leaves an artifact behind.
    • The migration contract: the schema and tables exist, and applying twice changes nothing and keeps rows. This replaces src/migrations.test.ts.
  • Deleted destructive-tests-gate, counts and preview unit tests. A route test now covers the counts walk across more than one page.
  • Deleted artifacts.test.ts cases that mount.test.ts already covers through routes.
  • The reference-host acceptance suite moves to tests/reference-host.test.ts and runs in bun run test. The test:acceptance script and its CI steps are gone.
    • The example is no longer its own package. The root tsconfig maps @corbits/artifacts to src/, and the example shares the test database URL helpers.
    • Its Interchange wiring now matches the 0.4.0 types.
    • @intx/hub-common and @intx/hub-sessions are now pinned devDependencies.
    • This also makes CL-9332's lockfile refresh moot, since the example's lockfile is gone.
  • On this branch stored upload bytes are not versioned (fix(uploads): store upload bytes per version #31 adds that), so version 2 in the round trip is a metadata-only revise that downloads the same bytes, and the test asserts that ?version=1 returns 400.
  • Stacked on feat(routes)!: replace mountArtifacts with createArtifactRoutes #28.

Verification

  • bun install --frozen-lockfile, typecheck clean
  • 334 tests pass (src + tests/, including the 42 acceptance scenarios) against Postgres 16, with the coverage floor met
  • build

Closes CL-9324
Closes CL-9149
Closes CL-9154
Closes CL-9140
Closes CL-9133
Closes CL-9136
Closes CL-9145

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
TheGreatAxios force-pushed the cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests branch 2 times, most recently from 449538e to 5dd69de Compare September 25, 2026 23:57
@TheGreatAxios
TheGreatAxios force-pushed the cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests branch from 5dd69de to e9c157f Compare September 26, 2026 01:29
@TheGreatAxios TheGreatAxios changed the title Move to real end-to-end tests in tests/ and cut duplicated unit tests test: add a real-Postgres harness for end-to-end suites in tests/ Sep 26, 2026
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
TheGreatAxios force-pushed the cl-9324-artifacts-add-shared-real-postgres-test-harness-in-tests branch from e9c157f to 9966d7b Compare September 26, 2026 01:37
@TheGreatAxios
TheGreatAxios added this pull request to stack #32 September 26, 2026 01:57
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