---
id: w5/m9/t005
title: Test coverage — meaningful tests for the read-only query behavior
worker: worker5
status: done
estimate: 30m
depends_on: [w5/m9/t002, w5/m9/t003]
---

## Objective

Add meaningful automated tests for what m6 shipped: the read-only envelope (session flags actually set), error mapping (not-found, RO violation, timeout), row-cap truncation, value-free errors/logs, and the MCP tool round-trip. Assert real behavior and failure modes — no trivial or tautological tests.

## Context

- Standing closing task; a dockertest/embedded-postgres (or the store's existing test DB pattern from w1/m2) can back the unit layer so t003's manual matrix has a regression net.

## Steps

1. Unit tests for the query helper against a test Postgres: RO rejection, timeout, cap.
2. Error-mapping tests asserting messages carry no SQL/values.
3. MCP round-trip test for `query_render_postgres`.

## Files

- `lego/backend/internal/postgres/*_test.go`

## Acceptance criteria

- [ ] Every t001–t003 acceptance criterion that can run in CI has a test; `go test ./...` green in `lego/backend`.

## Out of scope

- Coverage-percentage gaming; cluster e2e beyond t003.
