Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

36 lines · 1.6 KBRaw History
1import type { DiffineryEvent } from "@diffinery/shared";
2import { describe, expect, it } from "vitest";
3import type { Repo } from "../../src/lib/directory.js";
4import { webhookPayload } from "../../src/lib/webhook-payload.js";
5
6const BASE = "https://diffinery.example";
7const row = (visibility: Repo["visibility"]): Repo => ({
8 id: "r1",
9 owner_id: "u1",
10 owner_login: "octo",
11 owner_kind: "user",
12 name: "app",
13 description: "",
14 visibility,
15 default_branch: "main",
16 archived: 0,
17 created_at: "2026-01-01T00:00:00.000Z",
18 updated_at: "2026-01-01T00:00:00.000Z",
19 pushed_at: null,
20});
21const push: Extract<DiffineryEvent, { type: "push" }> = { type: "push", repoId: "r1", owner: "octo", repo: "app", ref: "refs/heads/main", before: "0".repeat(40), after: "a".repeat(40), forced: false, created: false, deleted: false, actor: { id: "u1", login: "octo", kind: "user" }, at: "2026-01-01T00:00:00.000Z" };
22
23describe("webhookPayload", () => {
24 it("reports a public repository as public, like GitHub", () => {
25 const body = webhookPayload(BASE, push, row("public"));
26 expect(body.repository).toMatchObject({ full_name: "octo/app", private: false, visibility: "public", default_branch: "main", owner: { login: "octo" } });
27 });
28
29 it("reports a private repository as private", () => {
30 expect(webhookPayload(BASE, push, row("private")).repository).toMatchObject({ private: true, visibility: "private" });
31 });
32
33 it("falls back to a minimal private repository when the directory row is gone", () => {
34 expect(webhookPayload(BASE, push, null).repository).toMatchObject({ full_name: "octo/app", private: true, visibility: "private" });
35 });
36});