Test Fixes (609/609 passing): - Fixed DiceSystem API to accept team_id/player_id parameters for audit trails - Fixed dice roll history timing issue in test - Fixed terminal client mock to match resolve_play signature (X-Check params) - Fixed result chart test mocks with missing pitching fields - Fixed flaky test by using groundball_a (exists in both batting/pitching) Documentation Updates: - Added Testing Policy section to backend/CLAUDE.md - Added Testing Policy section to tests/CLAUDE.md - Documented 100% unit test requirement before commits - Added git hook setup instructions Git Hook System: - Created .git-hooks/pre-commit script (enforces 100% test pass) - Created .git-hooks/install-hooks.sh (easy installation) - Created .git-hooks/README.md (hook documentation) - Hook automatically runs all unit tests before each commit - Blocks commits if any test fails All 609 unit tests now passing (100%) Integration tests have known asyncpg connection issues (documented) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| install-hooks.sh | ||
| pre-commit | ||
| README.md | ||
Git Hooks
This directory contains git hooks that enforce code quality and testing requirements.
Available Hooks
pre-commit
Purpose: Enforces 100% unit test passing before commits.
What it does:
- ✅ Runs all unit tests (
uv run pytest tests/unit/ -q) - ✅ Blocks commit if any test fails
- ✅ Shows clear error messages
- ✅ Fast execution (~1 second)
Installation:
# From repository root or backend directory
cd backend
./.git-hooks/install-hooks.sh
# Or manually:
cp .git-hooks/pre-commit ../.git/hooks/pre-commit
chmod +x ../.git/hooks/pre-commit
Usage:
# Normal commit - tests run automatically
git commit -m "Add feature X"
# Bypass hook for WIP commits (feature branches only!)
git commit -m "[WIP] Work in progress" --no-verify
# ⚠️ NEVER bypass on main branch
Troubleshooting:
If the hook fails:
-
Run tests manually to see detailed errors:
uv run pytest tests/unit/ -v -
Fix the failing tests
-
Try committing again
Uninstall:
rm ../.git/hooks/pre-commit
Why Git Hooks?
Benefits:
- 🛡️ Prevents broken code from being committed
- ⚡ Fast feedback (know immediately if you broke something)
- 📜 Clean history (main branch always deployable)
- 🎯 High confidence (609 tests verify behavior)
Philosophy:
- Unit tests are fast (<1 second) and should always pass
- If a test fails, it means you broke something
- Fix it before committing, not after
Adding New Hooks
To add a new hook:
- Create the hook script in
.git-hooks/ - Make it executable:
chmod +x .git-hooks/hook-name - Update
install-hooks.shto install it - Document it in this README
See Also
backend/CLAUDE.md→ "Testing Policy" sectionbackend/tests/CLAUDE.md→ "Testing Policy" section