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

Function makeTestDbLive

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

Source from the content-addressed store, hash-verified

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