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-hag9--test-suite-g...

48 lines
1.3 KiB
Markdown

---
# quotesdb-hag9
title: 'Test suite: GET /api/quotes/random — 200 with quote, 404 when database is empty'
status: completed
type: task
priority: normal
created_at: 2026-03-10T23:32:09Z
updated_at: 2026-03-10T23:32:17Z
blocked_by:
- quotesdb-gu9j
- quotesdb-l4e9
---
<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.
</context>
<goal>
Write the `GET /api/quotes/random` test suite in `tests/test_random_quote.rs` (or similar). Test cases:
1. 200 with a valid quote object when the database has quotes
2. 404 with `{"error": "..."}` when the database is empty
</goal>
<constraints>
- Use the shared test harness from ticket 9b581f.
- Test the 404 case against a fresh empty database (no seeded quotes).
- For the 200 case, seed at least one quote first.
</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 GET /api/quotes/random test suite`
</commit>