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

Function makeTestDbLive

apps/cloud/src/api.request-scope.node.test.ts:300–321  ·  view source on GitHub ↗
(state: StackProbeState)

Source from the content-addressed store, hash-verified

298 * acquired when the request fiber's scope opens, closed when it closes.
299 */
300const makeTestDbLive = (state: StackProbeState) =>
301 Layer.effect(TestDb)(
302 Effect.acquireRelease(
303 Effect.sync(() => {
304 const index = state.handles.length;
305 const handle: TestDbHandle = {
306 id: index + 1,
307 db: state.pool[index] as SqliteTestFumaDb,
308 closed: false,
309 };
310 state.handles.push(handle);
311 return handle;
312 }),
313 (handle) =>
314 // The request's own scope ends its connection, exactly as the host
315 // closes the postgres socket when the request finishes.
316 Effect.promise(async () => {
317 handle.closed = true;
318 await handle.db.close();
319 }),
320 ),
321 );
322
323/**
324 * The host's `stackLayer` seam, reduced to the parts that matter: a

Callers 1

makeStackProbeHandlerFunction · 0.85

Calls 3

pushMethod · 0.80
syncMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected