@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 68 lines 2.63 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { DBClusterEndpoint } from "@alchemy.run/aws/RDS";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as Provider from "alchemy/Provider";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 // Read-only `list()` path (default): resolve the provider from context via the
11 // typed `Provider.findProvider`, call `list()`, and assert a well-typed
12 // `Attributes[]` is returned. No deploy — spinning up an Aurora cluster + custom
13 // endpoint takes many minutes, far beyond the 240s budget. The account likely
14 // has zero custom cluster endpoints, so the array is typically empty; we only
15 // assert shape correctness here.
16 test.provider(
17 "list returns typed custom cluster endpoints",
18 () =>
19 Effect.gen(function* () {
20 const provider = yield* Provider.findProvider(DBClusterEndpoint);
21 const all = yield* provider.list();
22
23 expect(Array.isArray(all)).toBe(true);
24 for (const endpoint of all) {
25 expect(typeof endpoint.dbClusterEndpointIdentifier).toBe("string");
26 expect(Array.isArray(endpoint.staticMembers)).toBe(true);
27 expect(Array.isArray(endpoint.excludedMembers)).toBe(true);
28 expect(typeof endpoint.tags).toBe("object");
29 }
30 }),
31 { tags: ["provider:aws", "provider:aws:rds", "live"] },
32 );
33
34 // Full deploy-based `list()` verification, gated behind an env var because
35 // provisioning an Aurora DB cluster and a custom endpoint takes many minutes.
36 // Run with AWS_TEST_RDS_DBCLUSTER_ENDPOINT=1 on an account willing to pay the
37 // provisioning cost.
38 test.provider.skipIf(!process.env.AWS_TEST_RDS_DBCLUSTER_ENDPOINT)(
39 "list enumerates the deployed custom cluster endpoint",
40 (stack) =>
41 Effect.gen(function* () {
42 yield* stack.destroy();
43
44 const endpoint = yield* stack.deploy(
45 Effect.gen(function* () {
46 const cluster = yield* AWS.RDS.DBCluster("ListCluster", {
47 engine: "aurora-postgresql",
48 masterUsername: "alchemy",
49 manageMasterUserPassword: true,
50 });
51 return yield* DBClusterEndpoint("ListEndpoint", {
52 dbClusterIdentifier: cluster.dbClusterIdentifier,
53 endpointType: "READER",
54 });
55 }),
56 );
57
58 const provider = yield* Provider.findProvider(DBClusterEndpoint);
59 const all = yield* provider.list();
60
61 expect(
62 all.some((e) => e.dbClusterEndpointIdentifier === endpoint.dbClusterEndpointIdentifier),
63 ).toBe(true);
64
65 yield* stack.destroy();
66 }),
67 { tags: ["provider:aws", "provider:aws:rds", "live"] },
68 );