Files
oh-my-pi/packages/git-tool/test/cache.test.ts
T
can1357 b2c94bef1a refactor(deps): restructured codebase to use centralized pi-utils package
- Created new @oh-my-pi/pi-utils workspace package with shared utilities for logging, process management, stream handling, and temporary directory management.
- Migrated all packages to use centralized logger from @oh-my-pi/pi-utils instead of local winston implementations.
- Replaced custom process spawning and stream reading implementations with standardized cspawn and readLines utilities across all modules.
- Converted synchronous file operations and process spawning to async patterns using Bun shell syntax and fs/promises.
- Added streaming edit abort functionality with configurable setting to abort on patch preview failures.
- Updated test framework from vitest to bun:test across all test suites.
2026-01-20 05:33:21 +01:00

38 lines
1.2 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { gitTool } from "../src/git-tool";
import type { StatusResult, ToolResult } from "../src/types";
import { createTestRepo, type TestRepo } from "./helpers";
let repo: TestRepo;
let previousCwd: string;
beforeEach(() => {
previousCwd = process.cwd();
repo = createTestRepo();
process.chdir(repo.path);
});
afterEach(() => {
process.chdir(previousCwd);
repo.remove();
});
describe("git-tool cache", () => {
it("invalidates status cache on write operations", async () => {
repo.writeFile("file.txt", "hello");
repo.run("add", "file.txt");
repo.run("commit", "-m", "initial");
repo.writeFile("file.txt", "hello world");
const status1 = (await gitTool({ operation: "status" })) as ToolResult<StatusResult>;
expect(status1.data.modified.map((file) => file.path)).toContain("file.txt");
await gitTool({ operation: "add", paths: ["file.txt"] });
const status2 = (await gitTool({ operation: "status" })) as ToolResult<StatusResult>;
expect(status2.data.staged.map((file) => file.path)).toContain("file.txt");
expect(status2.data.modified.map((file) => file.path)).not.toContain("file.txt");
});
});