Skip to content
68 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { classify, hostPlatform, manifest, notesName, platformOfTriple } from "./desktop-release.mjs";
5
6test("each job's notes are named for the platforms they hold, so jobs on the same kind of machine do not overwrite each other", () => {
7 const linux = [{ platform: "linux", arch: "x64" }, { platform: "linux", arch: "x64" }];
8 const windows = [{ platform: "windows", arch: "x64" }];
9 assert.equal(notesName(linux), "collect-linux-x64.json");
10 assert.equal(notesName(windows), "collect-windows-x64.json");
11 assert.notEqual(notesName(linux), notesName(windows));
12 assert.equal(notesName([...windows, ...linux]), "collect-linux-x64+windows-x64.json");
13});
14
15test("a bundle's place in a release", () => {
16 assert.deepEqual(classify("g1t_0.1.0_x64-setup.exe", "windows-x64", "0.1.0"), {
17 platform: "windows",
18 arch: "x64",
19 kind: "installer",
20 name: "g1t-0.1.0-windows-x64-setup.exe",
21 updater: true,
22 });
23 assert.deepEqual(classify("g1t.app.tar.gz", "macos-arm64", "0.1.0"), {
24 platform: "macos",
25 arch: "arm64",
26 kind: "update",
27 name: "g1t-0.1.0-macos-arm64.app.tar.gz",
28 updater: true,
29 });
30 assert.equal(classify("g1t_0.1.0_aarch64.dmg", "macos-arm64", "0.1.0").kind, "dmg");
31 assert.equal(classify("g1t_0.1.0_amd64.AppImage", "linux-x64", "0.1.0").name, "g1t-0.1.0-linux-x64.AppImage");
32 assert.equal(classify("g1t_0.1.0_amd64.deb", "linux-x64", "0.1.0").updater, false);
33 assert.equal(classify("g1t-0.1.0-1.x86_64.rpm", "linux-x64", "0.1.0").kind, "rpm");
34 // Signatures ride with their file; an MSI is not published.
35 assert.equal(classify("g1t_0.1.0_x64-setup.exe.sig", "windows-x64", "0.1.0"), null);
36 assert.equal(classify("g1t_0.1.0_x64_en-US.msi", "windows-x64", "0.1.0"), null);
37});
38
39test("platforms, from a machine and from a target", () => {
40 assert.equal(hostPlatform("win32", "x64"), "windows-x64");
41 assert.equal(hostPlatform("darwin", "arm64"), "macos-arm64");
42 assert.equal(hostPlatform("linux", "x64"), "linux-x64");
43 assert.equal(platformOfTriple("x86_64-pc-windows-msvc"), "windows-x64");
44 assert.equal(platformOfTriple("aarch64-apple-darwin"), "macos-arm64");
45 assert.equal(platformOfTriple("debug"), null);
46});
47
48test("the manifest serves the updater and the download page", () => {
49 const entries = [
50 { platform: "windows", arch: "x64", kind: "installer", name: "g1t-0.1.0-windows-x64-setup.exe", updater: true, size: 10, sha256: "a", signature: "sig-win" },
51 { platform: "macos", arch: "arm64", kind: "update", name: "g1t-0.1.0-macos-arm64.app.tar.gz", updater: true, size: 20, sha256: "b", signature: "sig-mac" },
52 { platform: "macos", arch: "arm64", kind: "dmg", name: "g1t-0.1.0-macos-arm64.dmg", updater: false, size: 30, sha256: "c", signature: null },
53 { platform: "linux", arch: "x64", kind: "deb", name: "g1t-0.1.0-linux-x64.deb", updater: false, size: 40, sha256: "d", signature: null },
54 ];
55 const m = manifest(entries, "0.1.0", { date: "2026-10-11T00:00:00.000Z", notes: "First." });
56 assert.equal(m.version, "0.1.0");
57 assert.equal(m.notes, "First.");
58 assert.deepEqual(m.platforms, {
59 "windows-x86_64": { url: "https://g1t.sh/downloads/desktop/0.1.0/g1t-0.1.0-windows-x64-setup.exe", signature: "sig-win" },
60 "darwin-aarch64": { url: "https://g1t.sh/downloads/desktop/0.1.0/g1t-0.1.0-macos-arm64.app.tar.gz", signature: "sig-mac" },
61 });
62 // The update archive is the updater's alone; people download the disk image.
63 assert.deepEqual(
64 m.downloads.map((d) => d.name),
65 ["g1t-0.1.0-linux-x64.deb", "g1t-0.1.0-macos-arm64.dmg", "g1t-0.1.0-windows-x64-setup.exe"],
66 );
67 assert.deepEqual(m.downloads[1], { platform: "macos", arch: "arm64", kind: "dmg", name: "g1t-0.1.0-macos-arm64.dmg", size: 30, sha256: "c" });
68});