Run API tests against a dedicated test database#73
Merged
Conversation
vitest previously connected to the shared dev database, so every run left behind fixture studies and per-study DuckLake catalog schemas (53 ducklake_st_snap_* schemas were cleaned out of the dev DB once already, and they regrow on each pnpm check). The vitest config now derives a dedicated database by appending _test to the DATABASE_URL name (edc -> edc_test) and points LAKE_DATA_PATH at data/lake-test. A global setup drops and recreates that database fresh on every run — refusing to drop anything not named *_test — and wipes the test lake dir. TEST_DATABASE_URL overrides the derivation. With no reachable server, tests still skip locally and fail on CI, matching the existing per-file probes. CI works unchanged: the setup creates edc_test on the service container.
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
Fixes the dev-DB pollution flagged during the Python workbench work: every
pnpm checkrun left fixture studies and per-study DuckLake catalog schemas (ducklake_st_snap_*) in the shared dev database — 53 of them were manually cleaned out once already, and they regrow on each run.apps/api/vitest.config.ts: setsDATABASE_URLto a derived test database (_testappended to the name, soedc→edc_test) andLAKE_DATA_PATHtodata/lake-testfor all test workers.src/test/global-setup.ts: drops and recreates the test database fresh on every run and wipes the test lake dir, then runs migrations once (per-filerunMigrationscalls become no-ops under the existing advisory lock). Refuses to drop any database whose name doesn't end in_test.TEST_DATABASE_URLoverrides the derivation entirely.Behavior notes
DATABASE_URLstill points at the service container; setup createsedc_testthere. Theedcuser is the cluster superuser in both the compose stack and CI, soCREATE DATABASEneeds no new grants.Verification
edc_test).edc_test; parquet debris underdata/lake-test(gitignored),data/lakeuntouched.pnpm checkgreen.