A community based topic aggregation platform built on atproto

Lexicon validation documentation

+83
+83
TESTING_SUMMARY.md
··· 1 1 # Repository Testing Summary 2 2 3 + ## Lexicon Schema Validation 4 + 5 + We use Indigo's lexicon validator to ensure all AT Protocol schemas are valid and properly structured. 6 + 7 + ### Validation Components: 8 + 1. **Schema Validation** (`cmd/validate-lexicon/main.go`) 9 + - Validates all 57 lexicon schema files are valid JSON 10 + - Checks cross-references between schemas 11 + - Validates test data files against their schemas 12 + 13 + 2. **Test Data** (`tests/lexicon-test-data/`) 14 + - Contains example records for validation testing 15 + - Files use naming convention: 16 + - `*-valid*.json` - Should pass validation 17 + - `*-invalid-*.json` - Should fail validation (tests error detection) 18 + - Currently covers 5 record types: 19 + - social.coves.actor.profile 20 + - social.coves.community.profile 21 + - social.coves.post.record 22 + - social.coves.interaction.vote 23 + - social.coves.moderation.ban 24 + 25 + 3. **Validation Library** (`internal/validation/lexicon.go`) 26 + - Wrapper around Indigo's ValidateRecord 27 + - Provides type-specific validation methods 28 + - Supports multiple input formats 29 + 30 + ### Running Lexicon Validation 31 + ```bash 32 + # Full validation (schemas + test data) - DEFAULT 33 + go run cmd/validate-lexicon/main.go 34 + 35 + # Schemas only (skip test data validation) 36 + go run cmd/validate-lexicon/main.go --schemas-only 37 + 38 + # Verbose output 39 + go run cmd/validate-lexicon/main.go -v 40 + 41 + # Strict validation mode 42 + go run cmd/validate-lexicon/main.go --strict 43 + ``` 44 + 45 + ### Test Coverage Warning 46 + The validator explicitly outputs which record types have test data and which don't. This prevents false confidence from passing tests when schemas lack test coverage. 47 + 48 + Example output: 49 + ``` 50 + 📋 Validation Summary: 51 + Valid test files: 5/5 passed 52 + Invalid test files: 2/2 correctly rejected 53 + 54 + ✅ All test files behaved as expected! 55 + 56 + 📊 Test Data Coverage Summary: 57 + - Records with test data: 5 types 58 + - Valid test files: 5 59 + - Invalid test files: 2 (for error validation) 60 + 61 + Tested record types: 62 + ✓ social.coves.actor.profile 63 + ✓ social.coves.community.profile 64 + ✓ social.coves.post.record 65 + ✓ social.coves.interaction.vote 66 + ✓ social.coves.moderation.ban 67 + 68 + ⚠️ Record types without test data: 69 + - social.coves.actor.membership 70 + - social.coves.actor.subscription 71 + - social.coves.community.rules 72 + ... (8 more) 73 + 74 + Coverage: 5/16 record types have test data (31.2%) 75 + ``` 76 + 77 + ### Running Tests 78 + ```bash 79 + # Run lexicon validation tests 80 + go test -v ./tests/lexicon_validation_test.go 81 + 82 + # Run validation library tests 83 + go test -v ./internal/validation/... 84 + ``` 85 + 3 86 ## Test Infrastructure Setup 4 87 - Created Docker Compose configuration for isolated test database on port 5434 5 88 - Test database is completely separate from development (5433) and production (5432)