@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 53 lines 1.68 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Stripe from "@alchemy.run/stripe";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as Alchemy from "alchemy";
6 import * as Effect from "effect/Effect";
7 import * as Layer from "effect/Layer";
8 import { MinimumLogLevel } from "effect/References";
9 import StripeBindingWorker from "./fixtures/worker.ts";
10
11 const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
12 providers: Layer.mergeAll(Cloudflare.providers(), Stripe.providers()),
13 });
14 const { getWhenReady } = Test;
15
16 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
17
18 const Stack = Alchemy.Stack(
19 "StripeBindingTestStack",
20 {
21 providers: Layer.mergeAll(Cloudflare.providers(), Stripe.providers()),
22 state: Cloudflare.state(),
23 },
24 Effect.gen(function* () {
25 const worker = yield* StripeBindingWorker;
26 return { url: worker.url.as<string>() };
27 }),
28 );
29
30 const stack = beforeAll(deploy(Stack));
31 afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack));
32
33 test(
34 "deployed worker retrieves a bound Stripe product",
35 Effect.gen(function* () {
36 const { url } = yield* stack;
37 const response = yield* getWhenReady(`${url.replace(/\/+$/, "")}/product`);
38 expect(response.status).toBe(200);
39 const body = (yield* response.json) as { id: string; name: string };
40 expect(body.id).toMatch(/^prod_/);
41 expect(body.name).toEqual("Alchemy Bound Product");
42 }).pipe(logLevel),
43 {
44 tags: [
45 "provider:cloudflare",
46 "provider:cloudflare:worker",
47 "provider:stripe",
48 "provider:stripe:product",
49 "live",
50 ],
51 timeout: 180_000,
52 },
53 );