(state: StackProbeState)
| 298 | * acquired when the request fiber's scope opens, closed when it closes. |
| 299 | */ |
| 300 | const 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 |
no test coverage detected