The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Turso from "@alchemy.run/turso"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import * as HttpClient from "effect/http/HttpClient"; |
| 7 | import * as Layer from "effect/Layer"; |
| 8 | import * as Schedule from "effect/Schedule"; |
| 9 | import TursoLambda from "./fixtures/lambda.ts"; |
| 10 | import { LambdaDb } from "./fixtures/resources.ts"; |
| 11 | |
| 12 | const { test } = Test.make({ |
| 13 | providers: Layer.mergeAll(Turso.providers(), AWS.providers()), |
| 14 | }); |
| 15 | |
| 16 | test.provider( |
| 17 | "Connect + SQL.LibSQL and Drizzle.LibSQL query Turso from a Lambda", |
| 18 | (stack) => |
| 19 | Effect.gen(function* () { |
| 20 | yield* stack.destroy(); |
| 21 | const { url } = yield* stack.deploy( |
| 22 | Effect.gen(function* () { |
| 23 | yield* LambdaDb; |
| 24 | const fn = yield* TursoLambda; |
| 25 | return { url: fn.functionUrl }; |
| 26 | }), |
| 27 | ); |
| 28 | const http = HttpClient.filterStatusOk(yield* HttpClient.HttpClient); |
| 29 | const response = yield* http |
| 30 | .get(url!) |
| 31 | .pipe(Effect.retry({ schedule: Schedule.exponential("500 millis"), times: 8 })); |
| 32 | expect(yield* response.json).toEqual({ answer: 42, two: 2 }); |
| 33 | yield* stack.destroy(); |
| 34 | }), |
| 35 | { |
| 36 | tags: [ |
| 37 | "provider:turso", |
| 38 | "provider:turso:database", |
| 39 | "provider:aws", |
| 40 | "provider:aws:lambda", |
| 41 | "live", |
| 42 | ], |
| 43 | timeout: 300_000, |
| 44 | }, |
| 45 | ); |