import assert from "node:assert/strict"; import { test } from "node:test"; // A branch's protection (novox/hq ADR 0237): what the operator's agent sets so a pull request waits for the // mesh's merge check before it merges. test("the statuses asked for replace the rule's, and an empty list requires none", async () => { const { protectionBody } = await import("../protection.ts"); assert.deepEqual(protectionBody({ statusChecks: ["mesh/merge-gate", " mesh/repo-check", "", "mesh/merge-gate"] }, false), { enable_status_check: true, status_check_contexts: ["mesh/merge-gate", "mesh/repo-check"] }, "an edited rule keeps its pushes as they are, and each status once"); assert.deepEqual(protectionBody({ statusChecks: [] }, false), { enable_status_check: false, status_check_contexts: [] }); }); test("a new rule refuses direct pushes unless asked; an administrator's override only when said", async () => { const { protectionBody } = await import("../protection.ts"); assert.equal(protectionBody({ statusChecks: ["mesh/merge-gate"] }, true).enable_push, false); assert.equal(protectionBody({ statusChecks: ["mesh/merge-gate"], push: true }, true).enable_push, true); assert.equal(protectionBody({ statusChecks: ["mesh/merge-gate"] }, true).block_admin_merge_override, undefined); assert.equal(protectionBody({ statusChecks: ["mesh/merge-gate"], blockAdminOverride: true }, false).block_admin_merge_override, true); });