Skip to main content
Glama

MCP Git Server

by MementoRC
README.md•5.18 kB
# Test-Driven Development (TDD) Test Suite This test suite follows strict TDD principles to ensure requirements drive implementation. ## šŸ” TDD Governance Rules **CRITICAL**: Tests define requirements and are **IMMUTABLE** once marked complete. ### Test Modification Policy - āœ… **ALLOWED**: New tests for new requirements - āœ… **ALLOWED**: Test fixes for genuine bugs in test logic (with approval) - āŒ **FORBIDDEN**: Modifying tests to match implementation - āŒ **FORBIDDEN**: Removing tests that fail due to implementation issues ### Approval Process for Test Changes 1. Create GitHub issue explaining why test needs modification 2. Get approval from project maintainer 3. Document the requirement change that necessitates test change 4. Update tests with clear commit message referencing issue ## šŸ“ Test Structure (5-Layer Architecture) ``` tests/ ā”œā”€ā”€ unit/ # Layer 1-2: Primitives & Operations │ ā”œā”€ā”€ primitives/ # Atomic Git/GitHub operations │ ā”œā”€ā”€ operations/ # Composed operations │ ā”œā”€ā”€ types/ # Type system validation │ ā”œā”€ā”€ constants/ # Constants validation │ └── protocols/ # Protocol definitions ā”œā”€ā”€ integration/ # Layer 3: Services │ ā”œā”€ā”€ services/ # Service layer integration │ └── applications/ # Application integration ā”œā”€ā”€ system/ # Layer 4-5: Applications & Frameworks │ ā”œā”€ā”€ mcp_protocol/ # MCP protocol compliance │ └── server_lifecycle/ # Full server testing └── fixtures/ # Shared test data ā”œā”€ā”€ git_repos/ # Git repository fixtures ā”œā”€ā”€ github_responses/ # GitHub API response mocks └── mcp_messages/ # MCP protocol message fixtures ``` ## šŸ·ļø Test Markers Use pytest markers to categorize tests: - `@pytest.mark.unit` - Unit tests (fast, isolated) - `@pytest.mark.integration` - Integration tests (moderate speed) - `@pytest.mark.system` - End-to-end tests (slower) - `@pytest.mark.slow` - Tests taking >1 second - `@pytest.mark.requires_git` - Needs git repository setup - `@pytest.mark.requires_github` - Needs GitHub API access ## šŸš€ Running Tests ```bash # All tests uv run pytest # Unit tests only (fast feedback) uv run pytest -m unit # With coverage uv run pytest --cov=src --cov-report=html # Specific layer uv run pytest tests/unit/ uv run pytest tests/integration/ uv run pytest tests/system/ # Parallel execution uv run pytest -n auto ``` ## šŸ“Š Coverage Requirements - **Minimum**: 80% overall coverage (enforced by CI) - **Target**: 90%+ coverage for critical paths - **Primitives/Operations**: 95%+ coverage (foundational code) - **Services**: 85%+ coverage - **Applications**: 80%+ coverage ## šŸŽÆ TDD Workflow ### Red-Green-Refactor Cycle 1. **RED**: Write failing test that defines requirement 2. **GREEN**: Write minimal code to make test pass 3. **REFACTOR**: Improve code while keeping tests passing ### Test-First Development ```python # 1. FIRST: Write the test (should fail) def test_git_status_returns_clean_repo(): repo = GitRepository("/tmp/test-repo") status = repo.get_status() assert status.is_clean is True assert status.modified_files == [] # 2. THEN: Implement to make test pass class GitRepository: def get_status(self) -> GitStatus: # Minimal implementation to pass test pass ``` ## šŸ›”ļø Quality Gates Before any code commit: 1. āœ… All tests pass 2. āœ… Coverage >= 80% 3. āœ… No test modifications without approval 4. āœ… New functionality has corresponding tests 5. āœ… Tests follow naming conventions ## šŸ“š Test Writing Guidelines ### Test Naming Convention ```python def test_[component]_[action]_[expected_result](): # Example: test_git_status_returns_clean_repo() ``` ### Test Structure (AAA Pattern) ```python def test_example(): # ARRANGE: Set up test data repo = create_test_repository() # ACT: Execute the functionality result = repo.get_status() # ASSERT: Verify expectations assert result.is_clean is True ``` ### Mock External Dependencies ```python @pytest.mark.unit def test_github_api_call(mocker): # Mock external GitHub API mock_response = mocker.patch('requests.get') mock_response.return_value.json.return_value = {'status': 'success'} # Test internal logic without external dependency result = github_service.get_user('test') assert result['status'] == 'success' ``` ## šŸ”„ Continuous Integration Tests run automatically on: - Every commit to feature branches - Pull request creation/updates - Merge to main branch CI will **fail** if: - Any test fails - Coverage drops below 80% - Test modifications detected without proper approval ## 🚨 Emergency Procedures If tests are blocking critical fixes: 1. **NEVER** modify tests to make them pass 2. Create emergency branch with minimal fix 3. Document why tests need updating 4. Get approval for test modifications 5. Update tests in separate commit with clear reasoning Remember: **Tests are requirements, not obstacles!**

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MementoRC/mcp-git'

If you have feedback or need assistance with the MCP directory API, please join our Discord server