test(server): unit-test registry dispatch-by-type + worker lifecycle (#273 follow-up) #284

Merged
charles merged 1 commit from test/s11-registry into main 2026-04-23 23:07:03 +00:00
Collaborator

PR #273 reviewer flagged that the 7 extracted s11 modules had no dedicated tests. This fills the gap for registry.ts.

Coverage (12 tests)

  • registerWorker / getWorker / unregisterWorker lifecycle, incl. unknown-name no-op
  • getWorkers read-only view reflects insertions + deletions live
  • getWorkersByType filter + sort-by-name, unknown-type → []
  • findWorkerByUser hit/miss
  • getForemanWorker null-on-empty, found-with-host-mode, requires BOTH host_mode=true AND type="foreman"
  • listRunningTasksForIssue filters by both repo and issue_number
  • setAgentDeleteRunner / resetAgentDeleteRunner / getAgentDeleteRunner seam

Coverage gap (documented)

dispatchByType is not unit-tested through registry.ts. Six sibling suites (webhook-ci.test.ts, webhook-handlers.test.ts, webhook-post-merge.test.ts, webhook-assign-dedup.test.ts, breakdown.test.ts, force-merge.integration.test.ts) use mock.module("../domain/dispatch/registry", …), and Bun's mock.module is process-global and survives across files, so any in-file test would be shadowed under full-suite runs. The selection logic is fully covered by pool.test.ts; the registry's dispatchByType is a one-line pass-through to poolDispatchByType. If the wrapper is ever thickened, the sibling stubs should move to a janitor-style impl seam first.

Checks

  • bunx tsc --noEmit -p apps/server/tsconfig.json — EXIT=0
  • bun test apps/server/src/domain/dispatch/registry.test.ts — 12/12 pass
  • Full suite: 1019 pass / 4 pre-existing fails (+12 passes, 0 regressions)
PR #273 reviewer flagged that the 7 extracted s11 modules had no dedicated tests. This fills the gap for `registry.ts`. ## Coverage (12 tests) - `registerWorker` / `getWorker` / `unregisterWorker` lifecycle, incl. unknown-name no-op - `getWorkers` read-only view reflects insertions + deletions live - `getWorkersByType` filter + sort-by-name, unknown-type → `[]` - `findWorkerByUser` hit/miss - `getForemanWorker` null-on-empty, found-with-host-mode, requires BOTH `host_mode=true` AND `type="foreman"` - `listRunningTasksForIssue` filters by both `repo` and `issue_number` - `setAgentDeleteRunner` / `resetAgentDeleteRunner` / `getAgentDeleteRunner` seam ## Coverage gap (documented) `dispatchByType` is **not** unit-tested through `registry.ts`. Six sibling suites (`webhook-ci.test.ts`, `webhook-handlers.test.ts`, `webhook-post-merge.test.ts`, `webhook-assign-dedup.test.ts`, `breakdown.test.ts`, `force-merge.integration.test.ts`) use `mock.module("../domain/dispatch/registry", …)`, and Bun's `mock.module` is process-global and survives across files, so any in-file test would be shadowed under full-suite runs. The selection logic is fully covered by `pool.test.ts`; the registry's `dispatchByType` is a one-line pass-through to `poolDispatchByType`. If the wrapper is ever thickened, the sibling stubs should move to a janitor-style `impl` seam first. ## Checks - `bunx tsc --noEmit -p apps/server/tsconfig.json` — EXIT=0 - `bun test apps/server/src/domain/dispatch/registry.test.ts` — 12/12 pass - Full suite: 1019 pass / 4 pre-existing fails (+12 passes, 0 regressions)
test(server): unit-test registry dispatch-by-type + worker lifecycle (#273 follow-up)
All checks were successful
qa / qa (pull_request) Successful in 4m15s
qa / dockerfile (pull_request) Successful in 6s
abcce20b93
The dispatch/registry module was extracted from main.ts in #273 (S11
refactor) and had no dedicated test coverage — behaviour was only
exercised transitively through webhook/main suites. This adds a focused
12-test unit file covering the registry's public surface:

- registerWorker / getWorker / unregisterWorker lifecycle
- getWorkers read-only view reflects live insertions + deletions
- getWorkersByType filter + sort-by-name
- findWorkerByUser resolves by config.forgejo_user
- getForemanWorker requires BOTH host_mode=true AND type=foreman
- listRunningTasksForIssue filters by (repo, issue_number)
- setAgentDeleteRunner / resetAgentDeleteRunner DockerRunner seam

The registry's `dispatchByType` is a one-line delegate to
`pool.dispatchByType` and is covered by the existing pool.test.ts — plus
six sibling suites call `mock.module("../domain/dispatch/registry", …)`
to stub it, and Bun's module mocks are process-global, so any assertion
against the real scheduler in this file would be contaminated by
whichever sibling ran first. A comment block flags that limitation.

Cleanup follows the janitor.ts / pool.ts patterns — afterEach
unregisters every worker created in the test and resets the pool cursor
+ DockerRunner seam. No `mock.module`.
charles deleted branch test/s11-registry 2026-04-23 23:07:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!284
No description provided.