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.

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