Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

32 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { homebrewFormula } from "./cli-homebrew.mjs";
4
5const manifest = () => ({ version: "1.2.3", files: Object.fromEntries(
6 ["macos-arm64", "macos-x64", "linux-arm64", "linux-x64"].map((platform, i) =>
7 [platform, { name: `g1t-${platform}`, sha256: String(i).repeat(64) }]),
8) });
9
10test("Homebrew pins all four platforms to versioned, checksummed downloads", () => {
11 const m = manifest();
12 const formula = homebrewFormula(m);
13 for (const file of Object.values(m.files)) {
14 assert.ok(formula.includes(`/1.2.3/${file.name}\", using: :nounzip`));
15 assert.ok(formula.includes(`sha256 "${file.sha256}"`));
16 }
17 assert.ok(!formula.includes("/latest/"));
18 assert.match(formula, /bin.install .* => "g1t"/);
19 assert.match(formula, /g1t issue --help/);
20});
21
22test("reject incomplete manifests and unsafe Ruby interpolations", () => {
23 for (const change of [
24 (m) => { delete m.files["linux-x64"]; },
25 (m) => { m.version = '1.2.3"'; },
26 (m) => { m.files["macos-arm64"].name = "../g1t"; },
27 (m) => { m.files["linux-arm64"].sha256 = '"'; },
28 ]) {
29 const m = manifest(); change(m);
30 assert.throws(() => homebrewFormula(m));
31 }
32});