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