import { beforeEach, describe, expect, mock, test } from "bun:test";
import type { Viewer } from "~/lib/types";
import type { RequestCredential } from "../token-scope";
class StubEntrypoint {}
mock.module("cloudflare:workers", () => ({
env: { PUBLIC_URL: "https://forge.example.com" },
waitUntil: () => undefined,
WorkflowEntrypoint: StubEntrypoint,
DurableObject: StubEntrypoint,
WorkerEntrypoint: StubEntrypoint,
}));
mock.module("../repo-provisioning", () => ({
describeProvisioningError: () => "",
markProvisioningFailed: async () => undefined,
startProvisioning: async () => undefined,
RepoProvisionWorkflow: StubEntrypoint,
}));
const people: Record<string, Viewer> = Object.fromEntries(
["owner", "writer", "stranger"].map((name) => [
name,
{ id: `u-${name}`, name, displayName: null, email: `${name}@example.com`, isAdmin: false, emailVerified: true },
]),
);
const repo = {
id: "repo-1",
owner_id: "u-owner",
owner_name: "owner",
name: "app",
visibility: "public",
fork_of_id: null,
is_archived: 0,
default_branch: "main",
artifacts_name: "art-1",
description: null,
};
const PARENT_EXPIRY = Date.now() + 10 * 24 * 60 * 60 * 1000;
const inserted: string[] = [];
const existing = new Set(["label-1", "rule-1", "deploy-1"]);