Skip to content

Add unit coverage for /healthz responses #4

@devblac

Description

@devblac

Add unit coverage for /healthz responses

Context

While wiring the health endpoint into a load balancer, I realized we have no tests covering the /healthz JSON/status behavior. A regression here could cause false positives or hide real outages.

Problem

The health handler assembles status and component fields (db/rpc), but success and failure paths aren’t tested. We could accidentally change the shape or status codes without noticing.

Expected behavior

/healthz should return 200 with "ok" statuses when both checks pass. If either check fails, it should return 503 and mark the failing component as "fail" while keeping the JSON shape stable.

Scope / non-goals

Don’t change handler logic beyond test coverage; keep the response fields stable.

Acceptance criteria

  • Test covers the success path (200, statuses "ok").
  • Test covers failure path for db or rpc (503, failing component marked "fail").
  • JSON response includes status, db, and rpc keys when provided.

Hints

Use httptest in internal/health to stub checkers. Run go test ./internal/health.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions