---
id: w2/m8/t009
title: Test coverage — connection lifecycle, 503-when-unconfigured, token minting, pagination
worker: worker2
status: done
estimate: 40m
depends_on: [w2/m8/t007]
---

## Objective

Standing closing task. Add meaningful tests for what m8 shipped, asserting real behavior and failure modes — no tautological or snapshot-everything tests.

## Context

- Highest-value gaps to cover if earlier tasks didn't: connect→list→disconnect round-trip at the service level; forged `installation_id` rejected (token-mint validation); GitHub API error surfaces as a clean bex error not a 500; repo listing follows pagination; every git verb 503s with GitHub env or `BEX_CP_DB_URI` unset; authz denials (viewer can read connection, cannot connect/disconnect).

## Steps

1. Inventory existing coverage from t002–t006; fill the gaps above.
2. `cd lego/backend && go test ./...` green; dashboard tests green.

## Files

- `lego/backend/internal/github/*_test.go`; store test harness additions

## Acceptance criteria

- [ ] Failure modes above each have a test that fails if the behavior regresses

## Out of scope

- e2e cluster tests (the DoD's live check is t010's gate, not automated here)
