Description
src/routes/health.ts builds a HealthDependencyGraph across database, stellar-horizon, and db-pool dependencies and returns 200/503 based on aggregate status, but the degraded vs unhealthy aggregation and latency reporting need fuller test coverage. Expand src/routes/health.test.ts to exercise each dependency status combination.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/routes/health.ts, src/routes/health.test.ts, src/db/client.ts
- Aggregate must be
unhealthy/503 when any required dependency is down
Suggested execution
- Fork the repo and create a branch
git checkout -b test/health-dependency-graph
- Implement changes
- Inject mock db health and Stellar checkers returning up/degraded/down
- Assert aggregate status and HTTP code for each combination
- Assert
latencyMs and dependsOn are populated
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- DB up + Horizon down, all degraded, checker throws, missing optional dependency
- Include test output and notes
Example commit message
test: cover health dependency-graph aggregation
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
src/routes/health.tsbuilds aHealthDependencyGraphacrossdatabase,stellar-horizon, anddb-pooldependencies and returns 200/503 based on aggregate status, but the degraded vs unhealthy aggregation and latency reporting need fuller test coverage. Expandsrc/routes/health.test.tsto exercise each dependency status combination.Requirements and context
src/routes/health.ts,src/routes/health.test.ts,src/db/client.tsunhealthy/503 when any required dependency isdownSuggested execution
git checkout -b test/health-dependency-graphlatencyMsanddependsOnare populatedTest and commit
npm testExample commit message
test: cover health dependency-graph aggregationGuidelines