Skip to content

build: setup database testing infrastructure with factory-boy#4

Merged
itisnotyourenv merged 2 commits into
mainfrom
setup-db-for-tests
Aug 2, 2025
Merged

build: setup database testing infrastructure with factory-boy#4
itisnotyourenv merged 2 commits into
mainfrom
setup-db-for-tests

Conversation

@itisnotyourenv
Copy link
Copy Markdown
Owner

Summary

  • Setup comprehensive database testing infrastructure with isolated test database
  • Added factory-boy for model factories and test data generation
  • Created proper Docker setup for test database isolation
  • Enhanced test configuration and fixtures for better integration testing

Changes Made

  • Dependencies: Added factory-boy>=3.3.3 for test data factories
  • Docker Setup: Created docker-compose-test.yml with isolated PostgreSQL test database
  • Model Factories:
    • Created tests/utils/model_factories/user.py with UserFactory for test data generation
    • Proper base factory setup with database session integration
    • Fixture integration for seamless test data creation
  • Build Tools: Added justfile commands for test database management
    • just test-db-up - Start test database
    • just test-db-down - Stop test database
    • just test-db-reset - Reset test database
  • Test Configuration:
    • Updated test config to use dedicated test database (port 5435)
    • Enhanced integration test fixtures with proper database setup
    • Added user factory fixtures for easy test data creation

Test Infrastructure

  • ✅ Isolated test database prevents conflicts with development data
  • ✅ Factory-boy integration for realistic test data generation
  • ✅ Proper fixture setup for database sessions and model creation
  • ✅ Docker-based test database for consistent testing environment

Validation

  • Test database runs in isolation on port 5435
  • User factories create valid test data
  • Integration tests can use factory-generated data
  • Database fixtures properly manage test sessions
  • All existing tests continue to pass

🤖 Generated with Claude Code

itisnotyourenv and others added 2 commits August 2, 2025 20:37
- Added factory-boy dependency for model factories in tests
- Created user model factories with proper fixtures
- Setup docker-compose-test.yml for isolated test database
- Added justfile commands for test database management
- Updated test configuration to use dedicated test database
- Enhanced integration test setup with proper database fixtures

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@itisnotyourenv itisnotyourenv self-assigned this Aug 2, 2025
@itisnotyourenv itisnotyourenv merged commit 7e69b8e into main Aug 2, 2025
@itisnotyourenv itisnotyourenv deleted the setup-db-for-tests branch August 2, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant