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

Function makeFakeR2

apps/host-cloudflare/src/db/data-migrations.test.ts:35–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33};
34
35const makeFakeR2 = (): {
36 readonly bucket: R2Bucket;
37 readonly objects: Map<string, string>;
38} => {
39 const objects = new Map<string, string>();
40 // oxlint-disable-next-line executor/no-double-cast -- test double: only the R2 methods used by the migration are implemented
41 const bucket = {
42 get: async (key: string) => {
43 const value = objects.get(key);
44 return value === undefined ? null : { text: async () => value };
45 },
46 put: async (key: string, value: string) => {
47 objects.set(key, value);
48 },
49 head: async (key: string) => (objects.has(key) ? {} : null),
50 } as unknown as R2Bucket;
51 return { bucket, objects };
52};
53
54const insertIntegration = (
55 client: SqliteDataMigrationClient,

Callers 1

Calls 2

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected