52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { resolve } from "node:path";
|
|
import { test } from "bun:test";
|
|
|
|
import { rootPath } from "./config";
|
|
import { artifactInspectScript, parseWebProbeArtifactInspectOptions } from "./web-probe-artifact";
|
|
|
|
test("web-probe artifact inspect 只接受受控 artifact 路径和显式 SHA", () => {
|
|
const sha256 = `sha256:${"a".repeat(64)}`;
|
|
const options = parseWebProbeArtifactInspectOptions([
|
|
"inspect",
|
|
"--node", "D601",
|
|
"--lane", "v03",
|
|
"--path", ".state/web-probe-script/run.fixture/web-probe-script-report.json",
|
|
"--sha256", sha256,
|
|
]);
|
|
assert.equal(options.sha256, sha256);
|
|
const script = artifactInspectScript(options);
|
|
assert.match(script, /expectedSha256/u);
|
|
assert.match(script, /failureEvidence/u);
|
|
assert.match(script, /valuesRedacted/u);
|
|
assert.throws(() => parseWebProbeArtifactInspectOptions([
|
|
"inspect",
|
|
"--node", "D601",
|
|
"--lane", "v03",
|
|
"--path", "/tmp/secret.json",
|
|
"--sha256", sha256,
|
|
]), /受控 web-probe script artifact/u);
|
|
assert.equal(parseWebProbeArtifactInspectOptions([
|
|
"inspect",
|
|
"--node", "D601",
|
|
"--lane", "v03",
|
|
"--path", ".state/web-probe-script-artifacts/web-probe-script-d601-v03-fixture-report.json",
|
|
"--sha256", sha256,
|
|
]).path, ".state/web-probe-script-artifacts/web-probe-script-d601-v03-fixture-report.json");
|
|
const absolutePath = rootPath(".state/web-probe-script-artifacts/web-probe-script-d601-v03-fixture-report.json");
|
|
assert.equal(parseWebProbeArtifactInspectOptions([
|
|
"inspect",
|
|
"--node", "D601",
|
|
"--lane", "v03",
|
|
"--path", absolutePath,
|
|
"--sha256", sha256,
|
|
]).path, absolutePath);
|
|
assert.throws(() => parseWebProbeArtifactInspectOptions([
|
|
"inspect",
|
|
"--node", "D601",
|
|
"--lane", "v03",
|
|
"--path", resolve(".state/web-probe-script-artifacts/nested/report.json"),
|
|
"--sha256", sha256,
|
|
]), /受控 web-probe script artifact/u);
|
|
});
|