@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 71 lines 2.75 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 { assertRestApiDeleted } from "./assertions.ts";
7 import * as Test from "./Test.ts";
8
9 const { test } = Test.make({ providers: AWS.providers() });
10
11 // DeleteRestApi has a hard regional quota of roughly one request every 30s.
12 // Exercise create/read/list and both directions of the mutable media-type
13 // lifecycle on one deterministic API rather than provisioning and deleting
14 // four equivalent parents. Every former assertion remains out-of-band; the
15 // file now pays the deletion wall once.
16 test.provider.skipIf(!!process.env.FAST)(
17 "REST API lifecycle, binary media updates, and list",
18 (stack) =>
19 Effect.gen(function* () {
20 yield* stack.destroy();
21
22 const api = yield* stack.deploy(
23 Effect.gen(function* () {
24 return yield* AWS.ApiGateway.RestApi("AgRestApiLifecycle", {
25 endpointConfiguration: { types: ["REGIONAL"] },
26 binaryMediaTypes: ["application/octet-stream"],
27 });
28 }),
29 );
30
31 expect(api.restApiId).toBeDefined();
32 expect(api.rootResourceId).toBeDefined();
33 expect(api.binaryMediaTypes?.includes("application/octet-stream")).toBe(true);
34
35 const created = yield* ag.getRestApi({ restApiId: api.restApiId });
36 expect(created.id).toEqual(api.restApiId);
37
38 const provider = yield* Provider.findProvider(AWS.ApiGateway.RestApi);
39 const all = yield* provider.list();
40 expect(all.some((a) => a.restApiId === api.restApiId)).toBe(true);
41
42 yield* stack.deploy(
43 Effect.gen(function* () {
44 return yield* AWS.ApiGateway.RestApi("AgRestApiLifecycle", {
45 endpointConfiguration: { types: ["REGIONAL"] },
46 binaryMediaTypes: ["application/octet-stream", "image/png"],
47 });
48 }),
49 );
50
51 const widened = yield* ag.getRestApi({ restApiId: api.restApiId });
52 expect(widened.binaryMediaTypes?.includes("image/png")).toBe(true);
53
54 yield* stack.deploy(
55 Effect.gen(function* () {
56 return yield* AWS.ApiGateway.RestApi("AgRestApiLifecycle", {
57 endpointConfiguration: { types: ["REGIONAL"] },
58 binaryMediaTypes: ["image/png"],
59 });
60 }),
61 );
62
63 const narrowed = yield* ag.getRestApi({ restApiId: api.restApiId });
64 expect(narrowed.binaryMediaTypes?.includes("image/png")).toBe(true);
65 expect(narrowed.binaryMediaTypes?.includes("application/octet-stream")).toBe(false);
66
67 yield* stack.destroy();
68 yield* assertRestApiDeleted(api.restApiId);
69 }),
70 { tags: ["provider:aws", "provider:aws:apigateway", "live"] },
71 );