- conftest.py: pytest_configure guard rejects non-postgresql+asyncpg:// URLs before any test collects (per constitution §2.5/§5.2 v1.3.0) - docker-compose.test.yml: isolated postgres-test (5433) + minio-test (9002) + api-test runner; one command runs the full suite against real PostgreSQL - Makefile: test-unit and test-integration targets - .env.test.example: documents variables needed to run tests outside Docker - Fix pre-existing test bug: integration tests using client fixture (NoOpAuthProvider) for write operations (upload/delete/patch) now use authed_client with Bearer token — these were never caught because tests never ran against a live stack Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
1.9 KiB
YAML
68 lines
1.9 KiB
YAML
services:
|
|
postgres-test:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: reactbin
|
|
POSTGRES_PASSWORD: reactbin
|
|
POSTGRES_DB: reactbin_test
|
|
ports:
|
|
- "5433:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U reactbin"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
minio-test:
|
|
image: minio/minio:latest
|
|
command: server /data --console-address ":9001"
|
|
environment:
|
|
MINIO_ROOT_USER: minioadmin
|
|
MINIO_ROOT_PASSWORD: minioadmin
|
|
ports:
|
|
- "9002:9000"
|
|
- "9003:9001"
|
|
healthcheck:
|
|
test: ["CMD", "mc", "ready", "local"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
minio-init-test:
|
|
image: minio/mc:latest
|
|
depends_on:
|
|
minio-test:
|
|
condition: service_healthy
|
|
environment:
|
|
MINIO_ROOT_USER: minioadmin
|
|
MINIO_ROOT_PASSWORD: minioadmin
|
|
entrypoint: >
|
|
/bin/sh -c "
|
|
mc alias set local http://minio-test:9000 $$MINIO_ROOT_USER $$MINIO_ROOT_PASSWORD &&
|
|
mc mb --ignore-existing local/reactbin-test
|
|
"
|
|
|
|
api-test:
|
|
build:
|
|
context: ./api
|
|
environment:
|
|
TEST_DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@postgres-test:5432/reactbin_test
|
|
DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@postgres-test:5432/reactbin_test
|
|
S3_ENDPOINT_URL: http://minio-test:9000
|
|
S3_BUCKET_NAME: reactbin-test
|
|
S3_ACCESS_KEY_ID: minioadmin
|
|
S3_SECRET_ACCESS_KEY: minioadmin
|
|
S3_REGION: us-east-1
|
|
JWT_SECRET_KEY: test-secret-key-for-testing-only
|
|
OWNER_USERNAME: testowner
|
|
OWNER_PASSWORD: testpassword
|
|
API_BASE_URL: http://localhost:8000
|
|
MAX_UPLOAD_BYTES: "52428800"
|
|
depends_on:
|
|
postgres-test:
|
|
condition: service_healthy
|
|
minio-init-test:
|
|
condition: service_completed_successfully
|
|
command: ["python", "-m", "pytest", "tests/", "-v"]
|
|
working_dir: /app
|