import { beforeEach, describe, expect, mock, test } from "bun:test";
import { scopedTestState } from "./scoped.test-helper";
const kv = new Map<string, string>();
mock.module("cloudflare:workers", () => ({
env: {
SECRETS_KEY: "k".repeat(40),
PUBLIC_URL: "https://forge.test",
SITES_DOMAIN: "sites.test",
KV: {
get: async (key: string) => kv.get(key) ?? null,
put: async (key: string, value: string) => void kv.set(key, value),
delete: async (key: string) => void kv.delete(key),
},
},
waitUntil: () => undefined,
}));
mock.module("./directory", () => ({ forgetSiteDirectory: async () => undefined }));
const scoped = scopedTestState();
scoped.install();
const unpublished: string[] = [];
const actualDeploy = await import("./deploy");
mock.module("./deploy", () => ({
...actualDeploy,
assertLabelFree: async () => undefined,
loadSiteById: async () => null,
unpublishSite: async (id: string) => void unpublished.push(id),
activateSiteDeployment: async () => "active",
failSiteDeployment: async () => undefined,
insertDeployment: async () => ({ id: "d" }),
}));
mock.module("./scratch-git", () => ({
assertScratchRepoTransferable: async () => undefined,
createScratchRepo: async () => undefined,
sweepOrphanScratchRepos: async () => undefined,
transferScratchRepo: async () => undefined,
}));
const { backfillScratchExpiry, sweepScratchSites } = await import("./scratch");
const { scratchExpiryKey } = await import("./scratch-core");