Skip to content

Commit ff31ed5

Browse files
committed
test(manager): add coverage for minimum timeout enforcement
- Add test verifying timeout below 1s is clamped to 1s - Sort test cases alphabetically by name - Update existing timeout test wait duration for accuracy
1 parent 777cf27 commit ff31ed5

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

tests/utils/manager.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,33 @@ Deno.test(
301301
}
302302
)
303303

304+
Deno.test(
305+
'Utils.Manager.setProcessTimeout - enforces minimum 1 second timeout',
306+
{ sanitizeOps: false, sanitizeResources: false },
307+
async () => {
308+
const abortController = new AbortController()
309+
const childProcess = spawn('sleep', ['2'], { stdio: ['ignore', 'pipe', 'pipe'] })
310+
const id = Utils.Manager.registerProcess({
311+
command: 'sleep',
312+
args: ['2'],
313+
cwd: '/tmp',
314+
startTime: new Date(),
315+
background: false,
316+
exitCode: null,
317+
signal: null,
318+
stdout: '',
319+
stderr: '',
320+
abortController,
321+
process: childProcess
322+
})
323+
Utils.Manager.setProcessTimeout(id, 100)
324+
await new Promise(r => setTimeout(r, 500))
325+
assert(Utils.Manager.isProcessRunning(id))
326+
await new Promise(r => setTimeout(r, 1000))
327+
assert(!Utils.Manager.isProcessRunning(id))
328+
}
329+
)
330+
304331
Deno.test('Utils.Manager.setProcessTimeout - ignores unknown id', () => {
305332
Utils.Manager.setProcessTimeout('unknown', 1000)
306333
})
@@ -325,7 +352,7 @@ Deno.test(
325352
process: childProcess
326353
})
327354
Utils.Manager.setProcessTimeout(id, 100)
328-
await new Promise(r => setTimeout(r, 500))
355+
await new Promise(r => setTimeout(r, 1500))
329356
assert(!Utils.Manager.isProcessRunning(id))
330357
}
331358
)

0 commit comments

Comments
 (0)