test: provision integration databases with testcontainers - #29
Merged
Conversation
The PostgreSQL/MySQL integration suite now spins up ephemeral containers in code by default, so `pytest -m integration` needs no docker-compose stack. Set SQL2JSON_TEST_*_URL to reuse an external DB; test-integration.sh uses those overrides to drive compose. CI runs the testcontainers path.
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
The real-database integration suite (PostgreSQL + MySQL) now provisions ephemeral databases in code with testcontainers by default, alongside the existing docker-compose path. A bare
uv run --extra integration pytest -m integrationnow just works against any running Docker/Podman — no pre-provisioned stack required.Changes
tests/integration/conftest.py— session-scopedpg_url/mysql_urlfixtures startpostgres:16-alpine/mysql:8.0, seed the demosalestable fromdocker/initdb.sql, and tear the containers down. TheSQL2JSON_TEST_PG_URL/SQL2JSON_TEST_MYSQL_URLoverrides still win (reuse an external/compose DB, no seeding). Tests skip cleanly when no container runtime or driver is available.TESTCONTAINERS_RYUK_DISABLED=trueis set automatically (Ryuk is flaky under rootless Podman; containers are stopped explicitly).pyproject.toml—testcontainers[postgres,mysql]>=4.0added to the test-onlyintegrationextra (not core deps). Marker description updated.scripts/test-integration.sh— exports the override URLs so the compose stack is reused instead of starting nested testcontainers..github/workflows/ci.yml— theintegrationjob now runs the bare testcontainers path, so CI validates the new code on every run. Unit + integration both run in CI.CLAUDE.md,README.md,CHANGELOG.mdupdated.Verification
24 passed— 12 pg + 12 mysql.uv run pytest: 183 passed, 24 deselected.flake8,black --check,mypy: clean.