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.

48 lines
1.7 KiB
Markdown

+++
title = "Implement test server harness — spawn quotesdb-api with temp SQLite DB, return base URL"
priority = 8
status = "todo"
ticket_type = "task"
dependencies = ["ce1e4f", "5f5ba0", "2ab7a8", "fba598"]
+++
<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>
Implement a test server harness in `tests/helpers.rs` (or similar) that:
1. Creates a temporary SQLite database file (or in-memory DB)
2. Runs migrations to initialise the schema
3. Spawns the `quotesdb-api` binary on a random available port
4. Returns the base URL (e.g. `http://127.0.0.1:PORT`) for use in test functions
5. Cleans up (drops DB, stops server) when the test ends
</goal>
<constraints>
- Resolve TRIAGE ticket 2ab7a8 (workers-rs test binary compatibility) and 33ed29 (local dev config) before implementing.
- Resolve TRIAGE ticket fba598 (test isolation strategy: per-test DB vs transaction rollback) before deciding on isolation approach.
- The harness must be reusable across all test modules — import it as a shared helper.
- Each test must get a clean, isolated database state (no cross-test pollution).
</constraints>
<skills>
Use `superpowers:test-driven-development` — the harness is itself tested by running `cargo test`.
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): implement test server harness with temp SQLite DB`
</commit>