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.
vibed/quotesdb/.beans/quotesdb-h07r--test-suite-r...

50 lines
1.6 KiB
Markdown

---
# quotesdb-h07r
title: 'Test suite: router ordering — verify /api/quotes/random is not matched as :id parameter'
status: completed
type: task
priority: normal
created_at: 2026-03-10T23:32:11Z
updated_at: 2026-03-10T23:32:19Z
blocked_by:
- quotesdb-gu9j
- quotesdb-4t5j
---
<context>
Integration tests live in `tests/` and exercise the API binary against a temporary SQLite database. They run with `cargo test` and must not require a running Cloudflare environment. The test harness spawns the API server on a random port and returns the base URL.
The Axum router must register `GET /api/quotes/random` **before** `GET /api/quotes/:id`, otherwise the string `"random"` is matched as a path parameter value and the random endpoint is never reached.
</context>
<goal>
Write a test in `tests/test_router_order.rs` (or similar) that explicitly verifies `GET /api/quotes/random` is not matched as a `:id` parameter:
1. Seed at least one quote
2. Hit `GET /api/quotes/random` — assert 200 (or 200/404 if no quotes), not 404 for ID "random"
3. Confirm the response body is a quote object (if seeded), not an ID-not-found error
</goal>
<constraints>
- Use the shared test harness from ticket 9b581f.
- This test is a regression guard — if the router order is wrong, this test fails loudly.
</constraints>
<skills>
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 router ordering regression test for /api/quotes/random`
</commit>