Skip to content

test(acquisition): integration tests for acquisition pipeline (P103)#102

Merged
forkwright merged 1 commit intomainfrom
test/acquisition-integration
Mar 16, 2026
Merged

test(acquisition): integration tests for acquisition pipeline (P103)#102
forkwright merged 1 commit intomainfrom
test/acquisition-integration

Conversation

@forkwright
Copy link
Owner

Summary

  • Add 25 integration tests for the acquisition pipeline covering search, download queue, media requests, wanted list, auth enforcement, pipeline dispatch/completion/failure, and startup recovery
  • Build reusable test infrastructure: MockSearchService, MockEngine, MockImportService, in-memory SQLite, JWT auth helpers
  • Tests only — no production code changes

Test coverage

Area Tests Details
Search API 2 POST search with mock results, auth required
Download queue 6 Snapshot, enqueue, cancel, reprioritize, priority ordering, 404 on missing
Media requests 3 Submit, approve requires admin, deny requires admin
Wanted list 2 Add, remove
Auth enforcement 2 401 unauthenticated, 403 member on admin routes
Pipeline dispatch 2 Enqueue→engine dispatch, completion→import
Queue ordering 2 Priority tiers, FIFO within tier
Failure handling 3 Transient retry, permanent failure, budget exhaustion
Startup recovery 2 DB reload, HTTP visibility after recovery
Indexer 1 test_indexer endpoint

Observations

  1. BUG — indexer create status mismatch: create_indexer in paroche/src/routes/indexer.rs inserts status='unknown' but the 004_indexers.sql migration has CHECK(status IN ('active', 'degraded', 'failed')). Any successful create will fail with a constraint violation. Tests work around this by testing auth (403) which fires before the SQL.

  2. BUG — retry count not propagated in ActiveEntry: SyntaxisService::try_dispatch_next always creates ActiveEntry { retry_count: 0 } regardless of the actual retry count stored in the DB. This means on_download_failed always sees retry_count=0, so retry budget exhaustion only triggers when config.retry_count=0. The retry budget test works around this by setting retry_count: 0 in config. A fix would read retry_count from the DB or carry it on QueueItem.

  3. DEBT — download route SQL: download.rs uses raw SQL string formatting (format!("{SELECT_DOWNLOAD} WHERE ...")) rather than typed queries, making it fragile to schema changes.

Validation

cargo fmt --all -- --check  ✅
cargo clippy --workspace --all-targets -- -D warnings  ✅
cargo test --workspace  ✅ (25/25 integration + all unit tests)

Test plan

  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • cargo test --workspace — all tests pass
  • No production code modified

🤖 Generated with Claude Code

@github-actions
Copy link
Contributor

⚠️ Large PR detected — 14 files, 2985 lines changed.

Consider splitting into smaller PRs for easier review. Not a blocker, just a signal.

Add 25 integration tests covering:
- Search endpoint with mock DynSearchService (2 tests)
- Download queue CRUD: snapshot, enqueue, cancel, reprioritize (6 tests)
- Media request workflow with admin auth gates (3 tests)
- Wanted list CRUD (2 tests)
- Auth enforcement: 401 unauthenticated, 403 member-on-admin (2 tests)
- Pipeline: enqueue→dispatch, completion→import (2 tests)
- Queue ordering: priority tiers and FIFO within tier (2 tests)
- Failure handling: transient retry, permanent failure, budget exhaustion (3 tests)
- Startup recovery: DB reload and HTTP visibility (2 tests)
- Indexer test_indexer endpoint (1 test)

Test infrastructure:
- MockSearchService (canned JSON results via DynSearchService)
- MockEngine (records dispatched downloads via mpsc channel)
- MockImportService (records completed imports via mpsc channel)
- In-memory SQLite with full migration stack
- JWT auth helpers for admin/member tokens

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@forkwright forkwright force-pushed the test/acquisition-integration branch from c8080f0 to f54f039 Compare March 16, 2026 14:55
@forkwright forkwright merged commit 1ef567c into main Mar 16, 2026
@forkwright forkwright deleted the test/acquisition-integration branch March 16, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant