Publish DevRunbook source
Managed validation / full (push) Successful in 3m18s

This commit is contained in:
DevRunbook release export
2026-09-03 04:09:17 +02:00
commit cfd2804e27
928 changed files with 161642 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
import { describe, expect, it, vi } from 'vitest'
import type { JobStore } from '@devrunbook/application'
import { runWorkerLoop } from './worker-loop'
describe('worker loop', () => {
it('stops cleanly after an idle poll is aborted', async () => {
const controller = new AbortController()
const store = {
claim: vi.fn(async () => {
controller.abort()
return null
}),
} as unknown as JobStore
await runWorkerLoop({
store,
handlers: {},
workerId: 'worker-test',
nextLeaseId: () => 'lease-test',
leaseDurationMs: 30_000,
pollIntervalMs: 2_000,
signal: controller.signal,
})
expect(store.claim).toHaveBeenCalledOnce()
})
it('runs periodic planning before polling and contains planner failures', async () => {
const controller = new AbortController()
const order: string[] = []
const store = {
claim: vi.fn(async () => {
order.push('poll')
controller.abort()
return null
}),
} as unknown as JobStore
await runWorkerLoop({
store,
handlers: {},
workerId: 'worker-test',
nextLeaseId: () => 'lease-test',
leaseDurationMs: 30_000,
pollIntervalMs: 2_000,
signal: controller.signal,
schedule: async () => {
order.push('schedule')
throw new Error('temporary planner failure')
},
onScheduleError: vi.fn(),
})
expect(order).toEqual(['schedule', 'poll'])
})
})