---
id: w6/m1/t009
title: Test coverage — meaningful tests for the behavior this milestone shipped
worker: worker6
status: done
estimate: 30m
depends_on: [w6/m1/t007]
---

## Objective

Tests that assert the real lifecycle behavior and its failure modes — not tautologies. The high-value cases: atomic create (no partial state on FGA failure), the three limit guards, delete teardown completeness and idempotency, and authorization refusals.

## Context

- Backend test conventions: `lego/backend/` package tests; authz guard precedent is `TestAuthzGuardsEveryVerb` (w1/m9).
- Store tests run against the migration-applied schema.

## Steps

1. Core: create atomicity (inject FGA write failure → no tenant row), 6th-Hobby refusal, 26th-service refusal (suspended counted), `CanAddMember` matrix.
2. Delete: full teardown assertion + re-run-after-partial-failure completes; wrong confirmation → no side effects.
3. Authz: non-admin rename/delete refused; extend the guards-every-verb test to the new verbs.

## Files

- `lego/backend/internal/core/*_test.go`
- `lego/backend/internal/store/*_test.go`

## Acceptance criteria

- [ ] Every acceptance criterion in t003–t006 has a corresponding failing-mode test
- [ ] New verbs covered by the authz-guards test
- [ ] `go test ./...` green

## Out of scope

- Dashboard e2e (w6/m3/t005).
