Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

api.test.ts

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

api.test.tsBlame56 lines · 1 contributor
fc1817aClaude1import { describe, it, expect, beforeAll, afterAll } from "bun:test";
2import { join } from "path";
3import { rm, mkdir } from "fs/promises";
4import app from "../app";
5
6const TEST_REPOS = join(import.meta.dir, "../../.test-repos-api");
7
8beforeAll(async () => {
9 process.env.GIT_REPOS_PATH = TEST_REPOS;
10 process.env.DATABASE_URL = process.env.DATABASE_URL || "";
11 await mkdir(TEST_REPOS, { recursive: true });
12});
13
14afterAll(async () => {
15 await rm(TEST_REPOS, { recursive: true, force: true });
16});
17
18describe("API routes", () => {
19 it("GET / returns home page", async () => {
20 const res = await app.request("/");
21 expect(res.status).toBe(200);
22 const text = await res.text();
23 expect(text).toContain("gluecron");
24 });
25
26 it("GET /api/repos/:owner/:name returns 404 for missing repo", async () => {
27 // This will fail without DB, but verifies route exists
28 const res = await app.request("/api/repos/nobody/nothing");
29 // Without DB connection, this returns 500 or 404
30 expect([404, 500]).toContain(res.status);
31 });
32
33 it("POST /api/repos returns 400 without required fields", async () => {
34 const res = await app.request("/api/repos", {
35 method: "POST",
36 headers: { "Content-Type": "application/json" },
37 body: JSON.stringify({}),
38 });
39 // Without DB, might be 400 or 500
40 expect([400, 500]).toContain(res.status);
41 });
42});
43
44describe("Git HTTP routes", () => {
45 it("returns 400 for invalid service", async () => {
46 const res = await app.request("/test/repo.git/info/refs?service=invalid");
47 expect(res.status).toBe(400);
48 });
49
50 it("returns 404 for non-existent repo", async () => {
51 const res = await app.request(
52 "/nobody/nothing.git/info/refs?service=git-upload-pack"
53 );
54 expect(res.status).toBe(404);
55 });
56});