@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 86 lines 2.54 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { expect } from "@alchemy.run/test";
3 import * as ag from "@distilled.cloud/aws/api-gateway";
4 import * as Provider from "alchemy/Provider";
5 import * as Effect from "effect/Effect";
6 import { assertUsagePlanDeleted } from "./assertions.ts";
7 import * as Test from "./Test.ts";
8
9 const { test } = Test.make({ providers: AWS.providers() });
10
11 test.provider.skipIf(!!process.env.FAST)(
12 "create and delete usage plan",
13 (stack) =>
14 Effect.gen(function* () {
15 yield* stack.destroy();
16
17 const plan = yield* stack.deploy(
18 Effect.gen(function* () {
19 return yield* AWS.ApiGateway.UsagePlan("AgUsagePlan", { description: "test plan" });
20 }),
21 );
22
23 expect(plan.id).toBeDefined();
24
25 yield* stack.destroy();
26 yield* assertUsagePlanDeleted(plan.id);
27 }),
28 { tags: ["provider:aws", "provider:aws:apigateway", "live"] },
29 );
30
31 test.provider.skipIf(!!process.env.FAST)(
32 "usage plan throttle updates in place",
33 (stack) =>
34 Effect.gen(function* () {
35 yield* stack.destroy();
36
37 const plan = yield* stack.deploy(
38 Effect.gen(function* () {
39 return yield* AWS.ApiGateway.UsagePlan("AgUsagePlanThrottle", {
40 throttle: { burstLimit: 10, rateLimit: 100 },
41 });
42 }),
43 );
44
45 yield* stack.deploy(
46 Effect.gen(function* () {
47 return yield* AWS.ApiGateway.UsagePlan("AgUsagePlanThrottle", {
48 throttle: { burstLimit: 20, rateLimit: 200 },
49 });
50 }),
51 );
52
53 const remote = yield* ag.getUsagePlan({ usagePlanId: plan.id });
54 expect(remote.throttle?.burstLimit).toEqual(20);
55 expect(remote.throttle?.rateLimit).toEqual(200);
56
57 yield* stack.destroy();
58 yield* assertUsagePlanDeleted(plan.id);
59 }),
60 { tags: ["provider:aws", "provider:aws:apigateway", "live"] },
61 );
62
63 test.provider.skipIf(!!process.env.FAST)(
64 "list enumerates the deployed usage plan",
65 (stack) =>
66 Effect.gen(function* () {
67 yield* stack.destroy();
68
69 const plan = yield* stack.deploy(
70 Effect.gen(function* () {
71 return yield* AWS.ApiGateway.UsagePlan("AgUsagePlanList", {
72 description: "list test plan",
73 });
74 }),
75 );
76
77 const provider = yield* Provider.findProvider(AWS.ApiGateway.UsagePlan);
78 const all = yield* provider.list();
79
80 expect(all.some((p) => p.id === plan.id)).toBe(true);
81
82 yield* stack.destroy();
83 yield* assertUsagePlanDeleted(plan.id);
84 }),
85 { tags: ["provider:aws", "provider:aws:apigateway", "live"] },
86 );