t3-code-android-nightly/.repos/alchemy-effect/examples/aws-bedrock-ai/test/integ.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

37 lines
1.2 KiB
TypeScript

import * as Alchemy from "alchemy";
import * as AWS from "alchemy/AWS";
import * as Test from "alchemy/Test/Bun";
import { expect } from "bun:test";
import * as Effect from "effect/Effect";
import * as Schedule from "effect/Schedule";
import * as HttpClient from "effect/http/HttpClient";
import Stack from "../alchemy.run.ts";
const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
providers: AWS.providers(),
state: Alchemy.localState(),
});
const stack = beforeAll(deploy(Stack));
afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack));
test(
"generates text through Bedrock",
Effect.gen(function* () {
const out = (yield* stack) as { url: string };
const client = HttpClient.filterStatusOk(yield* HttpClient.HttpClient);
// Fresh function URLs take a few seconds to start serving 200s.
const res = yield* client
.get(`${out.url}?prompt=${encodeURIComponent("Say pong.")}`)
.pipe(
Effect.retry({
schedule: Schedule.exponential("1 second"),
times: 10,
}),
);
const body = (yield* res.json) as { text: string; finishReason: string };
expect(body.text.length).toBeGreaterThan(0);
}),
{ timeout: 300_000 },
);