initial import: @mikefreno/omp-pygenium (omp port)

This commit is contained in:
2026-08-10 09:46:09 -04:00
commit a40cdcd9e3
70 changed files with 12624 additions and 0 deletions

69
tests/registry.test.ts Normal file
View File

@@ -0,0 +1,69 @@
/**
* registry.test.ts — unit tests for the check registry.
*/
import { describe, expect, it, beforeEach } from "bun:test";
import {
clearChecks,
getAllChecks,
getCheck,
registerCheck,
type CheckDefinition,
} from "../src/checks/registry.js";
function stubCheck(name: string): CheckDefinition {
return {
name,
label: name,
description: `${name} check`,
agentName: "scanner",
phaseId: "scan",
buildScanTask: () => "scan",
buildFixTask: () => "fix",
gate: () => undefined,
};
}
describe("check registry", () => {
beforeEach(() => clearChecks());
it("registerCheck inserts and getAllChecks returns it", () => {
registerCheck(stubCheck("comments"));
const all = getAllChecks();
expect(all).toHaveLength(1);
expect(all[0]?.name).toBe("comments");
});
it("getCheck looks up by name", () => {
registerCheck(stubCheck("complexity"));
expect(getCheck("complexity")?.label).toBe("complexity");
expect(getCheck("missing")).toBeUndefined();
});
it("registerCheck throws on duplicate names", () => {
registerCheck(stubCheck("dup"));
expect(() => registerCheck(stubCheck("dup"))).toThrow(/Duplicate/);
});
it("registerCheck throws on invalid names", () => {
expect(() => registerCheck(stubCheck("Bad-Name"))).toThrow(/Invalid/);
expect(() => registerCheck(stubCheck("with space"))).toThrow(/Invalid/);
expect(() => registerCheck(stubCheck(""))).toThrow(/Invalid/);
});
it("clearChecks empties the registry", () => {
registerCheck(stubCheck("a"));
clearChecks();
expect(getAllChecks()).toHaveLength(0);
});
it("preserves insertion order", () => {
registerCheck(stubCheck("alpha"));
registerCheck(stubCheck("beta"));
registerCheck(stubCheck("gamma"));
expect(getAllChecks().map((c) => c.name)).toEqual([
"alpha",
"beta",
"gamma",
]);
});
});