MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeFakeD1

Function makeFakeD1

apps/host-cloudflare/src/db/data-migrations.test.ts:12–33  ·  view source on GitHub ↗
(client: SqliteDataMigrationClient)

Source from the content-addressed store, hash-verified

10const now = 1_780_000_000_000;
11
12const makeFakeD1 = (client: SqliteDataMigrationClient): D1Database => {
13 const prepare = (sql: string) => {
14 const statement = (args: readonly unknown[]): Record<string, unknown> => ({
15 bind: (...values: readonly unknown[]) => statement([...args, ...values]),
16 all: async () => {
17 const result = await client.execute({ sql, args });
18 return { success: true, meta: {}, results: result.rows };
19 },
20 run: async () => {
21 await client.execute({ sql, args });
22 return { success: true, meta: {}, results: [] };
23 },
24 });
25 return statement([]);
26 };
27
28 // oxlint-disable-next-line executor/no-double-cast -- test double: only the D1 methods used by the migration runner are implemented
29 return {
30 prepare,
31 withSession: () => ({ prepare }),
32 } as unknown as D1Database;
33};
34
35const makeFakeR2 = (): {
36 readonly bucket: R2Bucket;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected