Files
Peter Steinberger c70aee247e refactor(scripts): migrate JavaScript tools to TypeScript (#121005)
* refactor(scripts): migrate JavaScript tools to TypeScript

* fix(ci): keep changed-scope preflight zero-install

* fix(ci): preserve zero-install script owners

* fix(ci): complete script migration follow-through

* fix(release): keep stable closeout zero-install

* fix(scripts): preserve standalone execution boundaries

* fix(scripts): repair standalone loader boundaries

* fix(scripts): normalize gateway observation ids

* fix(scripts): keep Docker packager standalone

* test(scripts): preserve rebase cleanup helpers

* test(sessions): use tracked temp directory
2026-08-09 07:21:35 -07:00

42 lines
1.3 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { runGhCommand } from "../../scripts/lib/ghsa-patch-subprocess.mts";
describe("GHSA patch subprocess", () => {
it("bounds each GitHub lookup with a timeout and SIGKILL", () => {
const spawnSyncImpl = vi.fn(() => ({
status: 0,
stdout: "result",
stderr: "",
}));
expect(runGhCommand(["api", "rate_limit"], { spawnSyncImpl })).toBe("result");
expect(spawnSyncImpl).toHaveBeenCalledWith("gh", ["api", "rate_limit"], {
encoding: "utf8",
killSignal: "SIGKILL",
timeout: 60_000,
});
});
it("throws the GitHub CLI error when a lookup exits non-zero", () => {
const spawnSyncImpl = vi.fn(() => ({
status: 1,
stdout: "",
stderr: "gh api failed",
}));
expect(() => runGhCommand(["api", "rate_limit"], { spawnSyncImpl })).toThrow("gh api failed");
});
it("propagates the timeout error from a stalled GitHub CLI process", () => {
const timeout = Object.assign(new Error("spawnSync gh ETIMEDOUT"), { code: "ETIMEDOUT" });
const spawnSyncImpl = vi.fn(() => ({
error: timeout,
status: null,
stdout: "",
stderr: "",
}));
expect(() => runGhCommand(["api", "rate_limit"], { spawnSyncImpl })).toThrow(timeout);
});
});