The best way to control Claude Code, Codex and more from any computer or phone

main
ts 29 lines 1.31 KB
Raw
1 import { MssqlClient } from "@effect/sql-mssql"
2 import { assert, it } from "@effect/vitest"
3 import { Effect, Fiber, Redacted } from "effect"
4 import * as Reactivity from "effect/reactivity/Reactivity"
5 import { MssqlContainer } from "./utils.ts"
6
7 it.layer(MssqlContainer.layer, { timeout: "90 seconds" })((it) => {
8 it.effect("can query after interrupting a request in a single-connection pool", () =>
9 Effect.gen(function*() {
10 const container = yield* MssqlContainer
11 const client = yield* MssqlClient.make({
12 server: container.getHost(),
13 port: container.getPort(),
14 database: container.getDatabase(),
15 username: container.getUsername(),
16 password: Redacted.make(container.getPassword()),
17 encrypt: !("Deno" in globalThis),
18 trustServer: true,
19 minConnections: 1,
20 maxConnections: 1
21 })
22 // Start the request before interrupting it; do not wait for the server
23 // delay or give the cancellation acknowledgement time to arrive.
24 const pending = yield* client`WAITFOR DELAY '00:00:10'`.pipe(Effect.forkScoped({ startImmediately: true }))
25 yield* Fiber.interrupt(pending)
26 const rows = yield* client<{ value: number }>`SELECT 42 AS value`
27 assert.deepStrictEqual(rows, [{ value: 42 }])
28 }).pipe(Effect.provide(Reactivity.layer)))
29 })