+++ title = "Write unit tests in api/src/tests.rs covering all handlers, auth logic, and pagination" priority = 6 status = "todo" ticket_type = "task" dependencies = ["f3dc74", "2ce22e", "5dbb7d", "886bfd", "05f8ae", "5d9f5a", "b20b5a", "28e7d9"] +++ The `quotesdb` API is built with Axum + Tokio, targeting Cloudflare Workers via `workers-rs`. It serves JSON at `/api/*` endpoints and persists data to Cloudflare D1 (production) or a local SQLite file via Turso (development). Source lives in `src/bin/api/`. Shared types and utilities are in `src/lib.rs` — code placed there must compile for both the host target and `wasm32-unknown-unknown`. Write unit tests in `src/bin/api/tests.rs` (or a `#[cfg(test)]` module) covering all API handlers, the auth logic, and pagination calculations. Unit tests should test handler logic in isolation using mock or in-memory databases where possible. - Unit tests must run with `cargo test` on the host target — no WASM or browser context required. - Test auth code matching logic (correct code → pass, wrong code → 403). - Test pagination edge cases: page 1, last page, out-of-range page (empty array). - Test tag insertion and replacement (correct rows added/removed). - Aim for 80%+ code coverage of the API handler module. Use `superpowers:test-driven-development` throughout implementation — unit tests should already exist from prior tickets. Use `superpowers:verification-before-completion` before closing. Run in order from the `quotesdb/` directory: ```sh cargo fmt cargo check cargo clippy cargo test ``` `test(quotesdb): add unit tests for api handlers, auth logic, and pagination`