Files
open-design/tools/pack/tests/win-sign.test.ts
4b48f94b7c refactor(ci): align tools-pack sources with scope boundaries (#7230)
* refactor(ci): align tools-pack sources with scope boundaries

* refactor(tools-pack): unify test source imports

* fix(tools-pack): resolve workspace root from package

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* test(tools-pack): exercise bundled CLI directly

---------

Co-authored-by: Looper <looper@noreply.github.com>
2026-08-21 07:56:48 +00:00

68 lines
2.3 KiB
TypeScript

import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { resolveSigntoolPath } from "@/win/sign.js";
describe("resolveSigntoolPath", () => {
it("probes filesystem candidates before falling back to bare signtool", async () => {
const root = await mkdtemp(join(tmpdir(), "open-design-win-sign-"));
const kitSigntool = join(root, "Windows Kits", "signtool.exe");
try {
await mkdir(join(root, "Windows Kits"), { recursive: true });
await writeFile(kitSigntool, "");
await expect(resolveSigntoolPath("signtool.exe", ["signtool.exe", kitSigntool])).resolves.toBe(kitSigntool);
} finally {
await rm(root, { force: true, recursive: true });
}
});
it("falls back to bare signtool only after filesystem candidates are exhausted", async () => {
const root = await mkdtemp(join(tmpdir(), "open-design-win-sign-"));
try {
await expect(resolveSigntoolPath("signtool.exe", ["signtool.exe", join(root, "missing.exe")])).resolves.toBe(
"signtool.exe",
);
} finally {
await rm(root, { force: true, recursive: true });
}
});
it("keeps an explicit configured signtool path preferred", async () => {
const root = await mkdtemp(join(tmpdir(), "open-design-win-sign-"));
const configuredSigntool = join(root, "configured.exe");
const kitSigntool = join(root, "kit.exe");
try {
await writeFile(configuredSigntool, "");
await writeFile(kitSigntool, "");
await expect(resolveSigntoolPath(configuredSigntool, ["signtool.exe", kitSigntool])).resolves.toBe(
configuredSigntool,
);
} finally {
await rm(root, { force: true, recursive: true });
}
});
it("uses a filesystem fallback when an explicit configured signtool path is missing", async () => {
const root = await mkdtemp(join(tmpdir(), "open-design-win-sign-"));
const kitSigntool = join(root, "kit.exe");
try {
await writeFile(kitSigntool, "");
await expect(resolveSigntoolPath(join(root, "missing.exe"), ["signtool.exe", kitSigntool])).resolves.toBe(
kitSigntool,
);
} finally {
await rm(root, { force: true, recursive: true });
}
});
});