openclaw/test/scripts/sync-labels.test.ts
Peter Steinberger 7c70571683
chore(lint): clear 172 lint:all baseline violations in five batches (#118098)
* chore(lint): clean Android-Linux app assets batch

* chore(lint): clean setup-launcher-plugin batch

* chore(lint): clean changelog-updater batch

* chore(lint): clean QA-runtime-helper batch

* chore(lint): clean script-tests batch

* fix(mxc): await sandbox spawn before bridge selection

* fix(test): make fake plutil metacharacter escaping survive the template hop
2026-08-02 14:08:09 -07:00

48 lines
1.3 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const { execFileSyncMock } = vi.hoisted(() => ({
execFileSyncMock: vi.fn(),
}));
vi.mock("node:child_process", async () => {
const actual = await vi.importActual<typeof import("node:child_process")>("node:child_process");
return {
...actual,
execFileSync: execFileSyncMock,
};
});
describe("sync-labels", () => {
beforeEach(() => {
vi.resetModules();
execFileSyncMock.mockReset();
execFileSyncMock.mockImplementation((command: string, args?: readonly string[]) => {
if (command === "git") {
return "https://github.com/openclaw/openclaw.git\n";
}
if (command === "gh" && args?.some((arg) => arg.includes("/labels?"))) {
return "[]";
}
return "";
});
vi.spyOn(console, "log").mockImplementation(() => undefined);
});
afterEach(() => {
vi.restoreAllMocks();
});
it("bounds every GitHub CLI operation", async () => {
await import("../../scripts/sync-labels.ts");
const ghCalls = execFileSyncMock.mock.calls.filter(([command]) => command === "gh");
expect(ghCalls.length).toBeGreaterThan(1);
for (const call of ghCalls) {
const options = call[2];
expect(options).toMatchObject({
timeout: 120_000,
killSignal: "SIGKILL",
});
}
});
});