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

main
ts 72 lines 2.92 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { PodIdentityAssociation } from "@alchemy.run/aws/EKS";
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 // Ungated probe: `list()` enumerates every cluster, lists each cluster's pod
11 // identity associations, then hydrates each via `describePodIdentityAssociation`.
12 // It requires no deployed resource — in a clean account/region it returns `[]`,
13 // otherwise a well-formed array of full PodIdentityAssociation Attributes. This
14 // proves the enumeration wiring (listClusters -> listPodIdentityAssociations ->
15 // describePodIdentityAssociation) compiles and runs live without needing a
16 // ~10-minute cluster create.
17 test.provider(
18 "list returns a well-formed array of pod identity associations",
19 (stack) =>
20 Effect.gen(function* () {
21 yield* stack.destroy();
22
23 const provider = yield* Provider.findProvider(PodIdentityAssociation);
24 const all = yield* provider.list();
25
26 expect(Array.isArray(all)).toBe(true);
27 for (const association of all) {
28 expect(typeof association.associationArn).toBe("string");
29 expect(typeof association.associationId).toBe("string");
30 expect(typeof association.clusterName).toBe("string");
31 expect(typeof association.namespace).toBe("string");
32 expect(typeof association.serviceAccount).toBe("string");
33 expect(typeof association.roleArn).toBe("string");
34 }
35 }),
36 { tags: ["provider:aws", "provider:aws:eks", "live"] },
37 );
38
39 // Full deploy test: an EKS cluster takes ~10+ minutes to provision, which is far
40 // too heavy for CI. Gate the deploy behind a pre-existing cluster supplied via
41 // AWS_TEST_EKS_CLUSTER; an entitled account with a standing cluster runs this
42 // unchanged. Deploys an association, asserts it appears in the
43 // exhaustively-paginated `list()`, then tears down.
44 test.provider.skipIf(!process.env.AWS_TEST_EKS_CLUSTER)(
45 "list enumerates the deployed pod identity association",
46 (stack) =>
47 Effect.gen(function* () {
48 yield* stack.destroy();
49
50 const clusterName = process.env.AWS_TEST_EKS_CLUSTER!;
51 const roleArn = process.env.AWS_TEST_EKS_POD_ROLE_ARN!;
52
53 const association = yield* stack.deploy(
54 Effect.gen(function* () {
55 return yield* PodIdentityAssociation("ListPodIdentity", {
56 clusterName,
57 namespace: "default",
58 serviceAccount: "alchemy-test-list-sa",
59 roleArn,
60 });
61 }),
62 );
63
64 const provider = yield* Provider.findProvider(PodIdentityAssociation);
65 const all = yield* provider.list();
66
67 expect(all.some((a) => a.associationId === association.associationId)).toBe(true);
68
69 yield* stack.destroy();
70 }),
71 { tags: ["provider:aws", "provider:aws:eks", "live"], timeout: 600_000 },
72 );