import { describe, expect, mock, test } from "bun:test";
const fakeEnv: Record<string, string | undefined> = {
PUBLIC_URL: "https://gitfor.example.com",
INTEGRATIONS_ALLOW_LOOPBACK: "false",
SECRETS_KEY: "test-master-key",
WEBHOOKS_ALLOW_HTTP: undefined,
};
const dbCalls: Array<{ sql: string; params: unknown[] }> = [];
mock.module("cloudflare:workers", () => ({
env: fakeEnv,
waitUntil: () => undefined,
WorkflowEntrypoint: class {},
DurableObject: class {},
WorkerEntrypoint: class {},
}));
mock.module("../db", () => ({
run: async (sql: string, ...params: unknown[]) => {
dbCalls.push({ sql, params });
return { meta: { changes: 1 } };
},
first: async () => null,
all: async () => [],
stmt: () => ({}),
batch: async () => [],
placeholders: (count: number) => Array.from({ length: count }, () => "?").join(", "),
MAX_IN_LIST: 90,
chunks: <T>(items: T[]) => [items],
}));
const recordingDb = (scopeId: string) => ({
scopeId,
run: async (sql: string, ...params: unknown[]) => {
dbCalls.push({ sql, params });
return { meta: { changes: 1, last_row_id: 0 } };
},
first: async () => null,
all: async () => [],
batch: async () => [],
});
mock.module("../scoped-db", () => ({