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.

45 lines
1.5 KiB
Markdown

+++
title = "Test suite: router ordering — verify /api/quotes/random is not matched as :id parameter"
priority = 6
status = "todo"
ticket_type = "task"
dependencies = ["9b581f", "6e829e"]
+++
<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>