28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { readMaxWorkflowItems, readMaxWorkers } from "../src/config.ts";
|
|
|
|
test("worker configuration defaults to 16 and accepts only integers from 1 through 32", () => {
|
|
assert.deepEqual(readMaxWorkers(undefined), { value: 16 });
|
|
assert.deepEqual(readMaxWorkers("1"), { value: 1 });
|
|
assert.deepEqual(readMaxWorkers("32"), { value: 32 });
|
|
for (const invalid of ["0", "33", "-1", "1.5", "four", " 4"]) {
|
|
const result = readMaxWorkers(invalid);
|
|
assert.equal(result.value, 16);
|
|
assert.match(result.warning ?? "", /PI_SUBAGENT_MAX_WORKERS/);
|
|
}
|
|
});
|
|
|
|
test("workflow item configuration defaults to 32 and accepts only integers from 1 through 256", () => {
|
|
assert.deepEqual(readMaxWorkflowItems(undefined), { value: 32 });
|
|
assert.deepEqual(readMaxWorkflowItems(""), { value: 32 });
|
|
assert.deepEqual(readMaxWorkflowItems("1"), { value: 1 });
|
|
assert.deepEqual(readMaxWorkflowItems("32"), { value: 32 });
|
|
assert.deepEqual(readMaxWorkflowItems("256"), { value: 256 });
|
|
for (const invalid of ["0", "257", "-1", "2.5", "many", " 4"]) {
|
|
const result = readMaxWorkflowItems(invalid);
|
|
assert.equal(result.value, 32);
|
|
assert.match(result.warning ?? "", /PI_SUBAGENT_WORKFLOW_MAX_ITEMS/);
|
|
}
|
|
});
|