Files
openclaw/src/cli/worktrees-cli.test.ts
T

33 lines
1.1 KiB
TypeScript

import { Command } from "commander";
import { afterEach, describe, expect, it, vi } from "vitest";
import { managedWorktrees } from "../agents/worktrees/service.js";
import { resetConfigRuntimeState, setRuntimeConfigSnapshot } from "../config/config.js";
import { defaultRuntime } from "../runtime.js";
import { registerWorktreesCli } from "./worktrees-cli.js";
afterEach(() => {
vi.restoreAllMocks();
resetConfigRuntimeState();
});
describe("worktrees cli", () => {
it("passes session owner activity and built-in limits to gc", async () => {
setRuntimeConfigSnapshot({}, {});
const gc = vi.spyOn(managedWorktrees, "gc").mockResolvedValue({
removed: [],
orphansDeleted: 0,
snapshotsPruned: 0,
});
vi.spyOn(defaultRuntime, "log").mockImplementation(() => undefined);
const program = new Command().name("openclaw");
registerWorktreesCli(program);
await program.parseAsync(["worktrees", "gc"], { from: "user" });
expect(gc).toHaveBeenCalledWith({
limits: {},
shouldProtectOwner: expect.any(Function),
});
});
});