---
id: w7/m6/t006
title: Test coverage — meaningful tests for cross-App collision + reserved-host rejection
worker: worker7
status: todo
estimate: 30m
depends_on: [w7/m6/t004]
---

## Objective

Add meaningful tests asserting the real behavior and failure modes this milestone shipped: cross-App collision is rejected, the requesting App's own re-add stays idempotent, and reserved/platform hosts are rejected while the App's own auto host and free external domains succeed. No tautological or snapshot-everything tests.

## Context

- Backend service tests use the fake store (`lego/backend/internal/store/fake_test.go`) — model two Apps and assert the second cannot claim the first's host.
- Existing domain tests live alongside `lego/backend/internal/apps/` — extend them.

## Steps

1. Test cross-App collision: App B adding a host already registered on App A is rejected with the typed error; App A re-adding its own host is idempotent.
2. Test reserved-host: base-domain apex / dashboard host / foreign `<app>.<base>` are rejected; the App's own auto host and a free external domain succeed; `BEX_BASE_DOMAIN` unset ⇒ guard inert.
3. Test the adapter surface: the rejection maps to a 400/409 on REST (and equivalent on at least one other adapter).

## Files

- `lego/backend/internal/apps/*_test.go`
- `lego/backend/internal/store/*_test.go` (uniqueness index/lookup)

## Acceptance criteria

- [ ] Tests assert cross-App collision rejection + same-App idempotency and reserved-host rejection (with the own-auto-host and external-domain allow cases).
- [ ] At least one adapter-level test asserts the 400/409 mapping; `go test ./...` passes in `lego/backend`.

## Out of scope

- Live-cluster Ingress e2e; the Closeout DoD verification (t007).
