---
id: w4/m10/t006
title: Test coverage — meaningful tests for audit behavior
worker: worker4
status: done
estimate: 30m
depends_on: [w4/m10/t007]
---

## Objective

Add meaningful tests for what m10 shipped beyond t004's inventory pass: sink-failure isolation (verb succeeds when the sink errors), retention sweep behavior, read-surface authorization (admin 200 / member 403 / store-less 503), and filter correctness. Assert real behavior and failure modes — never trivial or tautological tests.

## Context

- Standing closing task; the store test patterns from w1/m2 back the persistence layer.

## Steps

1. Fake-sink and failing-sink unit tests around the core hook.
2. Store tests: write, tenant scoping, retention deletes.
3. Adapter tests for the read surface's auth matrix and filters.

## Files

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

## Acceptance criteria

- [x] Every t001–t003 acceptance criterion has a regression test; `go test ./...` green in `lego/backend`.

## Out of scope

- Coverage-percentage gaming; duplicate e2e beyond t004.
