Skip to content

test: comprehensive scheduler test suite (96 tests) - #137

Merged
aterrylu merged 1 commit into
mainfrom
terry/scheduler-tests
Apr 14, 2026
Merged

test: comprehensive scheduler test suite (96 tests)#137
aterrylu merged 1 commit into
mainfrom
terry/scheduler-tests

Conversation

@aterrylu

Copy link
Copy Markdown
Owner

Summary

Test Coverage

Test File Tests Covers
schedules-crud.test.ts 35 CRUD storage, name validation, run history JSONL append/prune
scheduler.test.ts 27 Engine init/stop, overlap policies (skip/allow/queue), concurrency queue + drain, isolated exec dispatch, agent exec dispatch, one-time schedules, catch-up, state management
schedules-api.test.ts 34 All 9 REST endpoints — validation (bad cron, bad target, missing fields, unsupported policies), happy paths, status/settings

What was untested before

The scheduler shipped with only 3 superficial tests (tool name existence checks). This PR adds coverage for:

  • Both execution modes (isolated claude -p + agent gateway send) — verified via injectable mock executors
  • Overlap policies — skip blocks when run active, allow passes through, queue/cancel return unsupported error
  • Concurrency limits — queuing at max capacity, queue draining on completion
  • Run state lifecycle — currentRunId set/cleared, consecutiveFailures increment/reset, runCount tracking
  • One-time schedules — future timer setup, past catch-up, invalid date handling
  • REST API validation — all required fields, target format, cron expression, overlap policy, duplicate names

Test plan

  • All 96 new tests pass
  • All 181 total tests pass (existing + new)
  • TypeScript type check clean
  • Biome lint/format clean

🤖 Generated with Claude Code

@nox-0x nox-0x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 96 tests covering scheduler engine (overlap policies, concurrency, execution dispatch, state management), REST API endpoints, and CRUD/run-history operations — exactly the coverage this feature needed.

Add three test files covering all scheduler layers:
- schedules-crud.test.ts: CRUD storage, name validation, run history JSONL
- scheduler.test.ts: engine init/stop, overlap policies, concurrency queue,
  isolated and agent execution dispatch, one-time schedules, catch-up
- schedules-api.test.ts: all 9 REST endpoints with validation and happy paths

Add test utilities to scheduler.ts: _resetForTesting(), _setExecutors(),
_onRunCompleted export — enables testing without spawning real Claude sessions
or gateway connections.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aterrylu
aterrylu force-pushed the terry/scheduler-tests branch from ed4ce83 to a01d451 Compare April 14, 2026 09:12
@aterrylu
aterrylu merged commit fb4d9d4 into main Apr 14, 2026
1 check passed
@aterrylu
aterrylu deleted the terry/scheduler-tests branch April 14, 2026 09:13
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.

2 participants