mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:01:24 +00:00
refactor(test): dedupe agent harnesses and routing fixtures
This commit is contained in:
42
src/agents/bash-process-registry.test-helpers.ts
Normal file
42
src/agents/bash-process-registry.test-helpers.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
||||
import type { ProcessSession } from "./bash-process-registry.js";
|
||||
|
||||
export function createProcessSessionFixture(params: {
|
||||
id: string;
|
||||
command?: string;
|
||||
startedAt?: number;
|
||||
cwd?: string;
|
||||
maxOutputChars?: number;
|
||||
pendingMaxOutputChars?: number;
|
||||
backgrounded?: boolean;
|
||||
pid?: number;
|
||||
child?: ChildProcessWithoutNullStreams;
|
||||
}): ProcessSession {
|
||||
const session: ProcessSession = {
|
||||
id: params.id,
|
||||
command: params.command ?? "test",
|
||||
startedAt: params.startedAt ?? Date.now(),
|
||||
cwd: params.cwd ?? "/tmp",
|
||||
maxOutputChars: params.maxOutputChars ?? 10_000,
|
||||
pendingMaxOutputChars: params.pendingMaxOutputChars ?? 30_000,
|
||||
totalOutputChars: 0,
|
||||
pendingStdout: [],
|
||||
pendingStderr: [],
|
||||
pendingStdoutChars: 0,
|
||||
pendingStderrChars: 0,
|
||||
aggregated: "",
|
||||
tail: "",
|
||||
exited: false,
|
||||
exitCode: undefined,
|
||||
exitSignal: undefined,
|
||||
truncated: false,
|
||||
backgrounded: params.backgrounded ?? false,
|
||||
};
|
||||
if (params.pid !== undefined) {
|
||||
session.pid = params.pid;
|
||||
}
|
||||
if (params.child) {
|
||||
session.child = params.child;
|
||||
}
|
||||
return session;
|
||||
}
|
||||
Reference in New Issue
Block a user