-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.test.ts
More file actions
57 lines (49 loc) · 1.46 KB
/
Copy pathgit.test.ts
File metadata and controls
57 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import assert from "node:assert/strict";
import { after, before, describe, it } from "node:test";
import {
cleanupBranches,
createWorktree,
getDiff,
getDiffStats,
getRepoRoot,
removeWorktree,
} from "./git.js";
describe("getRepoRoot", () => {
it("returns the repository root", async () => {
const root = await getRepoRoot();
assert.ok(root.length > 0);
assert.ok(root.includes("thinktank"));
});
});
describe("worktree lifecycle", () => {
let worktreePath: string;
it("creates a worktree", async () => {
worktreePath = await createWorktree(99);
assert.ok(worktreePath.length > 0);
assert.ok(worktreePath.includes("thinktank-agent-99"));
});
it("gets empty diff for unchanged worktree", async () => {
const diff = await getDiff(worktreePath);
assert.equal(diff, "");
});
it("gets empty diff stats for unchanged worktree", async () => {
const stats = await getDiffStats(worktreePath);
assert.deepEqual(stats.filesChanged, []);
assert.equal(stats.linesAdded, 0);
assert.equal(stats.linesRemoved, 0);
});
it("removes the worktree", async () => {
await removeWorktree(worktreePath);
// Should not throw
});
after(async () => {
// Clean up any leftover branches
await cleanupBranches().catch(() => {});
});
});
describe("cleanupBranches", () => {
it("runs without error even when no thinktank branches exist", async () => {
await cleanupBranches();
// Should not throw
});
});