mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:01:01 +00:00
test: share qa docker healthy deps
This commit is contained in:
@@ -5,6 +5,8 @@ import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { runQaDockerUp } from "./docker-up.runtime.js";
|
||||
|
||||
type QaDockerUpDeps = NonNullable<Parameters<typeof runQaDockerUp>[1]>;
|
||||
|
||||
async function occupyPortOrAcceptExisting(port: number): Promise<{ close: () => Promise<void> }> {
|
||||
const server = createServer();
|
||||
const listening = await new Promise<boolean>((resolve, reject) => {
|
||||
@@ -30,6 +32,20 @@ async function occupyPortOrAcceptExisting(port: number): Promise<{ close: () =>
|
||||
};
|
||||
}
|
||||
|
||||
function createHealthyDockerDeps(calls: string[]): QaDockerUpDeps {
|
||||
return {
|
||||
async runCommand(command, args, cwd) {
|
||||
calls.push([command, ...args, `@${cwd}`].join(" "));
|
||||
if (args.join(" ").includes("ps --format json openclaw-qa-gateway")) {
|
||||
return { stdout: '{"Health":"healthy","State":"running"}\n', stderr: "" };
|
||||
}
|
||||
return { stdout: "", stderr: "" };
|
||||
},
|
||||
fetchImpl: vi.fn(async () => ({ ok: true })),
|
||||
sleepImpl: vi.fn(async () => {}),
|
||||
};
|
||||
}
|
||||
|
||||
describe("runQaDockerUp", () => {
|
||||
it("builds the QA UI, writes the harness, starts compose, and waits for health", async () => {
|
||||
const calls: string[] = [];
|
||||
@@ -96,17 +112,7 @@ describe("runQaDockerUp", () => {
|
||||
bindUiDist: true,
|
||||
skipUiBuild: true,
|
||||
},
|
||||
{
|
||||
async runCommand(command, args, cwd) {
|
||||
calls.push([command, ...args, `@${cwd}`].join(" "));
|
||||
if (args.join(" ").includes("ps --format json openclaw-qa-gateway")) {
|
||||
return { stdout: '{"Health":"healthy","State":"running"}\n', stderr: "" };
|
||||
}
|
||||
return { stdout: "", stderr: "" };
|
||||
},
|
||||
fetchImpl: vi.fn(async () => ({ ok: true })),
|
||||
sleepImpl: vi.fn(async () => {}),
|
||||
},
|
||||
createHealthyDockerDeps(calls),
|
||||
);
|
||||
|
||||
expect(calls).toEqual([
|
||||
@@ -133,17 +139,7 @@ describe("runQaDockerUp", () => {
|
||||
usePrebuiltImage: true,
|
||||
skipUiBuild: true,
|
||||
},
|
||||
{
|
||||
async runCommand(command, args, cwd) {
|
||||
calls.push([command, ...args, `@${cwd}`].join(" "));
|
||||
if (args.join(" ").includes("ps --format json openclaw-qa-gateway")) {
|
||||
return { stdout: '{"Health":"healthy","State":"running"}\n', stderr: "" };
|
||||
}
|
||||
return { stdout: "", stderr: "" };
|
||||
},
|
||||
fetchImpl: vi.fn(async () => ({ ok: true })),
|
||||
sleepImpl: vi.fn(async () => {}),
|
||||
},
|
||||
createHealthyDockerDeps(calls),
|
||||
);
|
||||
|
||||
expect(result.outputDir).toBe(path.join(repoRoot, ".artifacts/qa-docker"));
|
||||
|
||||
Reference in New Issue
Block a user