From 9e34521f54f8ec29bc25628394e752b071e28197 Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Sat, 11 Jul 2026 03:37:09 -0700 Subject: [PATCH] test(miner-governor): close codecov/patch gap on kill-switch's repoFullName fallback PR #5012 (#2341, merged) landed with codecov/patch failing at 92.30% -- one partial branch never exercised: the root vitest test only ever supplied repoFullName on transitions, so buildMinerKillSwitchTransitionGovernorLedgerEvent's `input.repoFullName ?? null` fallback (kill-switch.ts:69) never took its null-producing side. Add a real, non-no-op transition (a genuine scope change) with repoFullName omitted, asserting the ledger row's repoFullName lands as null rather than undefined or omitted. kill-switch.ts now measures 100/100/100/100 via the same root vitest + vi.mock source-redirect path codecov actually reads (the engine package's own separate node:test suite, which this session had been using for local verification elsewhere, is invisible to codecov -- only files with a corresponding miner-lib wrapper exercised by a root vitest test are.) --- test/unit/miner-governor-kill-switch.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unit/miner-governor-kill-switch.test.ts b/test/unit/miner-governor-kill-switch.test.ts index 068f7d2514..fed52a50eb 100644 --- a/test/unit/miner-governor-kill-switch.test.ts +++ b/test/unit/miner-governor-kill-switch.test.ts @@ -72,6 +72,23 @@ describe("recordMinerKillSwitchTransition (#2341)", () => { expect(rows[0]?.id).toBeLessThan(rows[1]?.id ?? 0); }); + it("a transition with no repoFullName supplied records a null repoFullName, not an omitted or undefined one", () => { + const root = mkdtempSync(join(tmpdir(), "gittensory-miner-governor-kill-switch-no-repo-")); + roots.push(root); + const ledger = initGovernorLedger(join(root, "governor-ledger.sqlite3")); + ledgers.push(ledger); + + const tripped = recordMinerKillSwitchTransition( + { actionClass: "open_pr", previousScope: "none", scope: "global" }, + { append: (event) => ledger.appendGovernorEvent(event) }, + ); + + expect(tripped?.repoFullName).toBeNull(); + const rows = ledger.readGovernorEvents({}); + expect(rows).toHaveLength(1); + expect(rows[0]?.repoFullName).toBeNull(); + }); + it("is a no-op and appends nothing when the scope has not changed", () => { const root = mkdtempSync(join(tmpdir(), "gittensory-miner-governor-kill-switch-noop-")); roots.push(root);