Files
mesh-catalog/modules/mesh-catalog/test/heard.test.ts
T
jochen dbe2949f84
mesh/merge-gate head dbe2949f8456 merged into trunk 482232e8c51c — pass: builds mesh-catalog → novox; no bus step; every machine composes with the change a…
mesh/repo-check head dbe2949f8456 merged into trunk 482232e8c51c — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery delivered
mesh-catalog: pass over a build off its repository's trunk, as the controller does (ADR 0238)
A branch built through the build verb is a real build, and placing it would make it the catalogue's
current version though the controller never registers it. Say which of the controller's rules are
mirrored and which need its records.
2026-10-14 20:09:39 +02:00

73 lines
3.4 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { BUILD_EVENTS, placeable } from "../heard.js";
// A walk's build as the build seat says it (mesh-controller's link.BuildResult), here mailu's of novox/hq issue 712.
const walkBuild = {
id: "build-1791997333800041716",
repository: "http://novox.internal:20000/novox/mesh-catalog.git",
path: "modules/mailu",
ref: "main",
on: "shanks",
trunk: "main",
"on-trunk": true,
branches: ["main"],
module: "mailu",
commit: "e1c8965ddbf1cf9af9cf1eed7a72ae9ffa6d5a87",
manifest: { module: "mailu", unhealthy: { severity: "urgent", why: "mail stops" } },
made: [{ name: "code", kind: "bundle", reference: "artifact-store://mailu/code/blobs/sha256:d041" }],
};
test("the catalogue hears the build seat that builds now, not only the retired one (issue 712)", async () => {
assert.ok(BUILD_EVENTS.includes("node-build-agent.built"));
assert.ok(BUILD_EVENTS.includes("mesh-controller.built-before"));
// Subscribing is not enough: the mesh grants and routes only what the manifest consumes.
const manifest = JSON.parse(await readFile(new URL("../module.json", import.meta.url), "utf8"));
for (const heard of BUILD_EVENTS) assert.ok(manifest.consumes.includes(heard), `${heard} is not consumed`);
});
test("a walk's build is placed, under its module and commit", () => {
assert.deepEqual(placeable(walkBuild), { placed: "yes", module: "mailu", commit: walkBuild.commit });
// A walk that took the check's build of the same key says so, and is placed all the same (ADR 0350 §2).
assert.equal(placeable({ ...walkBuild, reused: "the check's build" } as never).placed, "yes");
});
test("a merge check, a try, a dry run and a failure are passed over without a fault", () => {
for (const [body, why] of [
[{ ...walkBuild, "check-outcome": { verdict: "passed" } }, "merge check"],
[{ ...walkBuild, check: { try: true } }, "merge check or a try"],
[{ ...walkBuild, "dry-run": true }, "dry run"],
[{ ...walkBuild, failed: "exit status 1" }, "failed"],
] as const) {
const placing = placeable(body);
assert.equal(placing.placed, "no");
if (placing.placed === "no") {
assert.match(placing.why, new RegExp(why));
assert.equal(placing.fault, false);
}
}
});
test("an outcome that names no module or commit is said as the builder's fault", () => {
const placing = placeable({ repository: walkBuild.repository, commit: walkBuild.commit });
assert.equal(placing.placed, "no");
if (placing.placed === "no") assert.equal(placing.fault, true);
});
test("a branch built through the build verb is passed over; a commit on the trunk, or from a seat that names none, is placed (ADR 0238)", () => {
const branch = { ...walkBuild, ref: "feature", "on-trunk": false, branches: ["feature"] };
const placing = placeable(branch);
assert.equal(placing.placed, "no");
if (placing.placed === "no") {
assert.match(placing.why, /not on its repository's trunk main/);
assert.equal(placing.fault, false);
}
// On the trunk by its branches although the seat did not set on-trunk.
assert.equal(placeable({ ...branch, branches: ["feature", "main"] }).placed, "yes");
// A seat older than the rule says no trunk: placed, as the controller lets it through.
const { trunk, "on-trunk": _on, branches, ...older } = walkBuild;
assert.equal(placeable(older).placed, "yes");
});