You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
Markdown
56 lines
1.9 KiB
Markdown
---
|
|
# quotesdb-kh9l
|
|
title: Write unit tests in api/src/tests.rs covering all handlers, auth logic, and pagination
|
|
status: completed
|
|
type: task
|
|
priority: normal
|
|
created_at: 2026-03-10T23:32:09Z
|
|
updated_at: 2026-03-10T23:32:17Z
|
|
blocked_by:
|
|
- quotesdb-l4e9
|
|
- quotesdb-nrue
|
|
- quotesdb-4gqi
|
|
- quotesdb-a0q1
|
|
- quotesdb-bz2v
|
|
- quotesdb-ode0
|
|
- quotesdb-753n
|
|
---
|
|
|
|
<context>
|
|
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`.
|
|
</context>
|
|
|
|
<goal>
|
|
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.
|
|
</goal>
|
|
|
|
<constraints>
|
|
- 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.
|
|
</constraints>
|
|
|
|
<skills>
|
|
Use `superpowers:test-driven-development` throughout implementation — unit tests should already exist from prior tickets.
|
|
Use `superpowers:verification-before-completion` before closing.
|
|
</skills>
|
|
|
|
<validation>
|
|
Run in order from the `quotesdb/` directory:
|
|
|
|
```sh
|
|
cargo fmt
|
|
cargo check
|
|
cargo clippy
|
|
cargo test
|
|
```
|
|
</validation>
|
|
|
|
<commit>
|
|
`test(quotesdb): add unit tests for api handlers, auth logic, and pagination`
|
|
</commit>
|