test: add job tests for BatchContentGeneration and ProcessContentTask #41

Merged
Snider merged 1 commit from test/job-tests into main 2026-02-23 06:09:51 +00:00
Member

Summary

Closes #10

  • Add tests/Feature/Jobs/BatchContentGenerationTest.php covering job configuration, queue assignment, tag generation, and job chaining (dispatch of ProcessContentTask per task)
  • Add tests/Feature/Jobs/ProcessContentTaskTest.php covering all execution paths in handle(), the failed() handler, retry logic, variable interpolation, the processOutput() stub behaviour, and entitlement/workspace integration

Test coverage

BatchContentGenerationTest

  • Job configuration: timeout, default priority, default batch size, ShouldQueue
  • Queue assignment to ai-batch with Queue::fake()
  • Tag generation (batch-generation + priority:* for all priority values)
  • Job chaining: verifies ProcessContentTask is dispatched per task on the ai queue

ProcessContentTaskTest

  • Job configuration: tries = 3, backoff = 60, timeout = 300, ShouldQueue
  • failed(): marks task failed with the exact exception message
  • handle() early exits: missing prompt, denied entitlement, unavailable provider
  • handle() success without workspace: no entitlement check, no usage recording
  • handle() success with workspace: entitlement check + recordUsage() called with correct metadata
  • processOutput() stub: no crash whether target is null or present (documents incomplete stub)
  • Variable interpolation: string replacement, array→JSON, unmatched placeholders left intact, empty input_data
  • Retry: re-dispatch after failure; failed() invoked on unhandled exception

Test plan

  • ./vendor/bin/pest --filter=Jobs passes in a host application with host-uk/core installed
  • PHP syntax verified clean on both files (php -l)

🤖 Generated with Claude Code

## Summary Closes #10 - Add `tests/Feature/Jobs/BatchContentGenerationTest.php` covering job configuration, queue assignment, tag generation, and job chaining (dispatch of `ProcessContentTask` per task) - Add `tests/Feature/Jobs/ProcessContentTaskTest.php` covering all execution paths in `handle()`, the `failed()` handler, retry logic, variable interpolation, the `processOutput()` stub behaviour, and entitlement/workspace integration ## Test coverage ### BatchContentGenerationTest - Job configuration: timeout, default priority, default batch size, `ShouldQueue` - Queue assignment to `ai-batch` with `Queue::fake()` - Tag generation (`batch-generation` + `priority:*` for all priority values) - Job chaining: verifies `ProcessContentTask` is dispatched per task on the `ai` queue ### ProcessContentTaskTest - Job configuration: `tries = 3`, `backoff = 60`, `timeout = 300`, `ShouldQueue` - `failed()`: marks task failed with the exact exception message - `handle()` early exits: missing prompt, denied entitlement, unavailable provider - `handle()` success without workspace: no entitlement check, no usage recording - `handle()` success with workspace: entitlement check + `recordUsage()` called with correct metadata - `processOutput()` stub: no crash whether target is null or present (documents incomplete stub) - Variable interpolation: string replacement, array→JSON, unmatched placeholders left intact, empty `input_data` - Retry: re-dispatch after failure; `failed()` invoked on unhandled exception ## Test plan - [ ] `./vendor/bin/pest --filter=Jobs` passes in a host application with `host-uk/core` installed - [ ] PHP syntax verified clean on both files (`php -l`) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Clotho added 1 commit 2026-02-23 00:57:17 +00:00
test: add job tests for BatchContentGeneration and ProcessContentTask (#10)
Some checks failed
CI / PHP 8.2 (pull_request) Failing after 1s
CI / PHP 8.3 (pull_request) Failing after 1s
CI / PHP 8.4 (pull_request) Failing after 1s
CI / Assets (pull_request) Failing after 1s
26b0f19f4c
- tests/Feature/Jobs/BatchContentGenerationTest.php
  - job configuration (timeout, priority, batch size, ShouldQueue)
  - queue assignment to ai-batch with Queue::fake()
  - tag generation (batch-generation + priority:*)
  - job chaining: ProcessContentTask dispatch per task
  - handle() empty-collection path (documented alias-mock limitation)

- tests/Feature/Jobs/ProcessContentTaskTest.php
  - job configuration (tries, backoff, timeout, ShouldQueue)
  - failed() marks task failed with exception message
  - handle() early-exit: missing prompt
  - handle() early-exit: denied entitlement
  - handle() early-exit: unavailable provider
  - handle() success without workspace (no usage recording)
  - handle() success with workspace (entitlement check + usage recording)
  - processOutput() stub behaviour (target absent/present, no crash)
  - variable interpolation: strings, arrays, unmatched placeholders, empty data
  - retry logic: re-dispatch, failed() called on unhandled exception

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Snider merged commit 48547dc214 into main 2026-02-23 06:09:51 +00:00
Snider deleted branch test/job-tests 2026-02-23 06:09:51 +00:00
Sign in to join this conversation.
No description provided.