swadhinbiswas feat: OpenCodeHub v1.1.0 - Enterprise Features & Storage Adapters · 2/15/2026
719a1cb
43 lines · 1.1 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
import { getCommits, initRepository } from "@/lib/git";
import fs from "fs/promises";
import path from "path";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

const TEST_REPO_PATH = path.join(
  process.cwd(),
  "data",
  "test-repos",
  "integration-test.git"
);

describe("Git Integration", () => {
  beforeAll(async () => {
    await fs.rm(TEST_REPO_PATH, { recursive: true, force: true });
  });

  afterAll(async () => {
    await fs.rm(TEST_REPO_PATH, { recursive: true, force: true });
  });

  it("should initialize a repository", async () => {
    await initRepository(TEST_REPO_PATH, {
      repoName: "integration-test",
      ownerName: "tester",
      readme: true,
      skipHooks: true,
    });

    const exists = await fs
      .stat(TEST_REPO_PATH)
      .then(() => true)
      .catch(() => false);
    expect(exists).toBe(true);
  });

  it("should get commits", async () => {
    const commits = await getCommits(TEST_REPO_PATH);
    expect(commits.length).toBeGreaterThan(0);
    expect(commits[0].message).toBe("Initial commit");
  });
});