---
id: w8/m5/t008
title: Test coverage for Database/KeyValue metering
worker: worker8
status: todo
estimate: 35m
depends_on: [w8/m5/t006]
---

## Objective

Add meaningful tests for the Database/KeyValue metering behavior this milestone ships — real behavior and failure modes, not tautological coverage.

## Context

- `lego/backend/internal/usage/service_acceptance_test.go` is the existing acceptance-test pattern for the App-only pipeline.
- `service_test.go` covers unit-level rollup logic.

## Steps

1. Extend the acceptance test to seed a Database and KeyValue instance and assert their `instance_seconds` rows appear correctly.
2. Add unit tests for the new k8s-client listing helper (t002) and the resource-kind field (t003).
3. Assert the skip behavior for `egress_bytes`/`build_seconds` on these kinds (per t001) is intentional, not accidental.

## Files

- `lego/backend/internal/usage/service_test.go`
- `lego/backend/internal/usage/service_acceptance_test.go`

## Acceptance criteria

- [ ] Tests fail if Database/KeyValue instances stop being metered, or if `egress_bytes`/`build_seconds` rows start appearing for them unintentionally.

## Out of scope

- Dashboard UI tests (covered under t005's own scope if needed).
