Files
oh-my-pi/packages/coding-agent/test/extensibility/custom-commands/ci-green.test.ts
T
can1357 bc39ffa265 feat: introduced omptype validation package and migrated workspace dependencies
- Introduce `@oh-my-pi/omptype` as a new ArkType-compatible schema validation package featuring a lazy JIT runtime, JSON Schema emission, and compatibility adapters.
- Replace `arktype` across workspace packages and test utilities with `@oh-my-pi/omptype`.
- Add benchmark suites, tests, and documentation for the new validation engine and adapters.
- Update workspace build, test runner, and release configurations to include the new package.
2026-08-03 21:56:48 +02:00

51 lines
1.6 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "bun:test";
import * as arktype from "@oh-my-pi/omptype";
import type * as TypeBox from "@oh-my-pi/omptype/typebox";
import * as zod from "@oh-my-pi/omptype/zod";
import * as piCodingAgent from "@oh-my-pi/pi-coding-agent";
import { GreenCommand } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/bundled/ci-green";
import type { CustomCommandAPI } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/types";
import type { HookCommandContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types";
import * as git from "@oh-my-pi/pi-coding-agent/utils/git";
afterEach(() => {
vi.restoreAllMocks();
});
function createApi(): CustomCommandAPI {
return {
cwd: "/tmp/test",
exec: async () => ({
stdout: "",
stderr: "",
code: 0,
killed: false,
}),
typebox: {} as unknown as typeof TypeBox,
arktype,
zod,
pi: piCodingAgent,
};
}
describe("GreenCommand", () => {
it("includes tag instructions when HEAD has a tag", async () => {
vi.spyOn(git.ref, "tags").mockResolvedValue(["v0.1.0-alpha2"]);
const command = new GreenCommand(createApi());
const result = await command.execute([], {} as HookCommandContext);
expect(result).toContain("v0.1.0-alpha2");
expect(result).not.toContain("timeouts due to the harnesses");
});
it("omits tag instructions when HEAD is not tagged", async () => {
vi.spyOn(git.ref, "tags").mockResolvedValue([]);
const command = new GreenCommand(createApi());
const result = await command.execute([], {} as HookCommandContext);
expect(result).not.toContain("v0.1.0-alpha2");
});
});