feat: add omx team adapter skeleton
This commit is contained in:
60
tests/omx-team-smoke-script.test.ts
Normal file
60
tests/omx-team-smoke-script.test.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
function runSmoke(payload: unknown) {
|
||||
return new Promise<{
|
||||
exitCode: number | null;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}>((resolve, reject) => {
|
||||
const scriptPath = path.resolve("scripts/omx-team-smoke.mjs");
|
||||
const child = spawn(process.execPath, [scriptPath], {
|
||||
cwd: "/Users/kris/code/boss",
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
child.stdout.setEncoding("utf8");
|
||||
child.stderr.setEncoding("utf8");
|
||||
child.stdout.on("data", (chunk) => {
|
||||
stdout += chunk;
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
stderr += chunk;
|
||||
});
|
||||
child.on("error", reject);
|
||||
child.on("close", (exitCode) => {
|
||||
resolve({ exitCode, stdout, stderr });
|
||||
});
|
||||
|
||||
child.stdin.write(JSON.stringify(payload));
|
||||
child.stdin.end();
|
||||
});
|
||||
}
|
||||
|
||||
test("omx team smoke script emits ready JSON for valid payload", async () => {
|
||||
const result = await runSmoke({
|
||||
requestKind: "dispatch_execution",
|
||||
workersRequested: 2,
|
||||
objective: "并行协作链路 smoke",
|
||||
});
|
||||
|
||||
assert.equal(result.exitCode, 0);
|
||||
assert.equal(result.stderr, "");
|
||||
const parsed = JSON.parse(result.stdout);
|
||||
assert.equal(parsed.status, "ready");
|
||||
assert.equal(parsed.backendId, "omx-team");
|
||||
assert.match(parsed.summary, /并行协作链路 smoke/);
|
||||
});
|
||||
|
||||
test("omx team smoke script emits failed JSON for invalid payload", async () => {
|
||||
const result = await runSmoke("not-an-object");
|
||||
|
||||
assert.equal(result.exitCode, 0);
|
||||
const parsed = JSON.parse(result.stdout);
|
||||
assert.equal(parsed.status, "failed");
|
||||
assert.match(parsed.error, /INVALID_OMX_PAYLOAD/);
|
||||
});
|
||||
Reference in New Issue
Block a user