test(server): API integration tests with Axum test harness (COD-380) - #7
Conversation
Add tests/api_test.rs covering all public /api/v1/* HTTP endpoints:
- Health check
- Content CRUD (create, list, get, delete)
- Variant creation
- Workflow state transitions (valid, chained, invalid, missing)
- Schedule creation and listing (valid, invalid UUID/date)
Also fix pre-existing axum 0.8 route syntax bug: api.rs used :id
captures (axum 0.7 syntax) which panic at runtime in axum 0.8.
Changed to {id} captures.
23 integration tests pass. Full suite: 79 tests pass.
Review panel (GPT-5.5 + Gemini 3 Flash) flagged that pointing IrisClient at localhost:8090 risked the /health test making a real HTTP connection if something was listening on that port. Changed to 127.0.0.1:1 (privileged port, never listening) so all Iris health checks fail immediately with connection-refused.
🤖 Automated Review PanelGPT-5.5 (openai/gpt-5.5)Verdict: ✅ Approve. The change achieves the stated goal, all CI gates are green, and the work is correct. What was verified:
Goal alignment: Every required test case from COD-380 is present. Bonus coverage includes 400 on invalid UUID, invalid schedule date, missing-title 422, chained transitions, delete verification. Correctness: No bugs found. The route-syntax bug fix is real and critical — Conventions: No violations. No storage read-modify-write logic touched, no Platform parsing via serde introduced, no text-length comparisons touched. Recommendation: Merge as-is. Gemini 3 Flash (google/gemini-3-flash-preview)Verdict: Ship-worthy for the core goal, with two notes addressed. What was verified: All 23 tests pass, full workspace green, clippy clean, fmt clean. The Issues flagged (both addressed post-review):
Bottom line: The route-syntax fix alone is a genuine, correctly-scoped bug fix that justifies part of the PR. API test coverage is comprehensive and matches the task spec. |
Auto-Merge Gate — ApprovedConfidence: 0.92 (threshold: 0.80) Rationale: PR fully satisfies COD-380 acceptance criteria — all 8 required API endpoint test cases are covered (23 tests total, including bonus edge cases). CI gates all green: Formatting, Clippy, Tests, Build, Secret Scanning. Review panel (GPT-5.5 + Gemini 3 Flash) both approved with no blocking issues. The Checks observed: Formatting ✅, Clippy ✅, Tests ✅ (79 total), Build ✅, Secret Scanning ✅ Scope: 2 files changed (1 new test file + 5-line route syntax fix). No secrets, auth, deployment, billing, or destructive changes touched. Linear: COD-380 — no manual-review markers in issue description or comments. |
Summary
Closes COD-380
Adds comprehensive integration tests for PostGhost's public
/api/v1/*HTTP API endpoints. Previously, only the storage layer had test coverage — every API regression went undetected until manual testing.Changes
New file:
crates/postghost-server/tests/api_test.rs(23 tests)Uses
axum::body::Body+tower::ServiceExt::oneshotagainst in-memory SQLite (SqliteStorage::in_memory()). IrisClient points at127.0.0.1:1(never listening) to ensure no real network calls during tests.Coverage:
GET /healthreturns status okBug fix:
crates/postghost-server/src/api.rsPre-existing route syntax bug: routes used
:idcaptures (axum 0.7 syntax) but the project depends on axum 0.8, which requires{id}syntax. This causedbuild_router_from_arc()to panic at runtime — meaning the server would crash on startup. Changed all 5 route definitions to{id}.Verification
Review Panel
Both reviewers approved. See review panel comment below.