Skip to content

fix(docker): make the compose test path pass without a lockfile or a localhost Redis - #173

Merged
rennf93 merged 1 commit into
masterfrom
fix/docker-test-path
Oct 21, 2026
Merged

rennf93 merged 1 commit into
masterfrom
fix/docker-test-path

Conversation

@rennf93

@rennf93 rennf93 commented Oct 21, 2026

Copy link
Copy Markdown
Member

make test (the compose test service, pytest -v --cov=guard --cov-branch) gave 41 failed on master. It gives 0 failed here.

  1. uv.lock is gitignored in this repo (git ls-files uv.lock prints nothing), but the Dockerfile ran uv sync --extra dev --frozen and compose.yml bind-mounted ./uv.lock. On a clean clone the build failed with Unable to find lockfile and, once the file was missing, Docker created a directory called uv.lock on the host and the mount failed with not a directory. I copied the guard-core pattern: uv sync --extra dev without --frozen and no uv.lock mount.
  2. The engine's SecurityConfig defaults to enable_redis=True and redis_url=redis://localhost:6379. Tests that build a config without a redis_url therefore connect to localhost:6379 inside the test container, where no Redis listens, and the middleware answers 503. Tests that hardcoded the URL now read REDIS_URL the way the conftest does, and a session fixture in tests/conftest.py points the engine default at REDIS_URL when it is set (it does nothing when REDIS_URL is unset, so the CI service container on localhost still works). Files: tests/test_decorators/test_middleware_integration.py, tests/test_middleware/test_redis_unavailable_response.py, tests/conftest.py.

Verification, the compose test service run as the Makefile runs it, in an own compose project with Redis without a host port (the Makefile target itself runs docker compose down --rmi all -v and docker system prune -f, so I did not run it), master vs this branch:

  • Python 3.10: master 446 passed, 41 failed; branch 487 passed, 0 failed.
  • Python 3.14: master 446 passed, 41 failed; branch 487 passed, 0 failed.
  • Master runs used a locally generated uv.lock, because master does not build without one.
  • The example service from compose.yml on this branch: healthy, GET / 200, uid=10001 (Python 3.10).
  • hadolint 2.15.1 on the Dockerfile: no output.

Not verified: Python versions other than 3.10 and 3.14, and the CI result (see the checks on this PR).

@rennf93 rennf93 added the no-issue Chore or dependency PR that does not need an issue label Oct 21, 2026
@github-actions github-actions Bot added area: middleware Touches guard/middleware.py (ASGI middleware adapter) area: decorators Touches FastAPI-specific decorator wiring or re-exports tests Test suite changes build Makefile / Docker / setup.py / packaging labels Oct 21, 2026
@rennf93
rennf93 merged commit 46ec054 into master Oct 21, 2026
17 checks passed
@rennf93
rennf93 deleted the fix/docker-test-path branch October 27, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: decorators Touches FastAPI-specific decorator wiring or re-exports area: middleware Touches guard/middleware.py (ASGI middleware adapter) build Makefile / Docker / setup.py / packaging no-issue Chore or dependency PR that does not need an issue tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant