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

Function makeStoreHarness

apps/cloud/src/auth/jwks-cache.node.test.ts:75–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74/** Stands in for the Workers Cache API: shared across "isolates", in memory. */
75const makeStoreHarness = (): StoreHarness => {
76 const entries = new Map<string, StoredJwks>();
77 let reads = 0;
78 let writes = 0;
79 return {
80 get: async (url) => {
81 reads++;
82 return entries.get(url.toString()) ?? null;
83 },
84 put: async (url, stored) => {
85 writes++;
86 entries.set(url.toString(), stored);
87 },
88 seed: (stored) => {
89 entries.set(jwksUrl.toString(), stored);
90 },
91 reads: () => reads,
92 writes: () => writes,
93 };
94};
95
96/** A fetch that always fails, standing in for a slow/down key server. */
97const failingFetch: typeof globalThis.fetch = async () => {

Callers 1

Calls 3

toStringMethod · 0.80
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected