@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 101 lines 3.77 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { AttributeGroup } from "@alchemy.run/aws/AppRegistry";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as appregistry from "@distilled.cloud/aws/service-catalog-appregistry";
6 import * as Data from "effect/Data";
7 import * as Effect from "effect/Effect";
8 import * as Schedule from "effect/Schedule";
9 import { makeAppRegistryTestLease } from "./TestLease.ts";
10
11 const { test, beforeAll, afterAll } = Test.make({ providers: AWS.providers() });
12 const serviceLease = makeAppRegistryTestLease();
13
14 beforeAll(serviceLease.acquire, { timeout: 3_600_000 });
15 afterAll(serviceLease.release);
16
17 class AttributeGroupStillExists extends Data.TaggedError("AttributeGroupStillExists")<{
18 specifier: string;
19 }> {}
20
21 const assertAttributeGroupGone = (specifier: string) =>
22 appregistry.getAttributeGroup({ attributeGroup: specifier }).pipe(
23 Effect.flatMap(() => Effect.fail(new AttributeGroupStillExists({ specifier }))),
24 Effect.catchTag("ResourceNotFoundException", () => Effect.void),
25 Effect.retry({
26 while: (e) => e._tag === "AttributeGroupStillExists",
27 schedule: Schedule.max([Schedule.fixed("2 seconds"), Schedule.recurs(10)]),
28 }),
29 );
30
31 // AppRegistry is in maintenance mode (see Application.test.ts) — lifecycle
32 // tests only run on accounts that retain access via AWS_TEST_APPREGISTRY=1.
33 test.provider.skipIf(!process.env.AWS_TEST_APPREGISTRY)(
34 "creates, updates, and deletes an attribute group",
35 (stack) =>
36 Effect.gen(function* () {
37 yield* stack.destroy();
38
39 const created = yield* stack.deploy(
40 Effect.gen(function* () {
41 const group = yield* AttributeGroup("TestAttributes", {
42 description: "attribute group lifecycle test",
43 attributes: { owner: "platform-team", costCenter: "1234" },
44 tags: { purpose: "lifecycle" },
45 });
46 return {
47 attributeGroupId: group.attributeGroupId,
48 attributeGroupArn: group.attributeGroupArn,
49 attributeGroupName: group.attributeGroupName,
50 };
51 }),
52 );
53 expect(created.attributeGroupArn).toContain(":servicecatalog:");
54
55 // out-of-band verify via distilled
56 const found = yield* appregistry.getAttributeGroup({
57 attributeGroup: created.attributeGroupId,
58 });
59 expect(found.name).toBe(created.attributeGroupName);
60 expect(found.description).toBe("attribute group lifecycle test");
61 expect(JSON.parse(found.attributes ?? "{}")).toEqual({
62 owner: "platform-team",
63 costCenter: "1234",
64 });
65 expect(found.tags?.purpose).toBe("lifecycle");
66 expect(found.tags?.["alchemy::id"]).toBe("TestAttributes");
67
68 // in-place update of attributes, description, and tags
69 yield* stack.deploy(
70 Effect.gen(function* () {
71 yield* AttributeGroup("TestAttributes", {
72 description: "updated description",
73 attributes: {
74 owner: "commerce-team",
75 costCenter: "5678",
76 tier: 1,
77 },
78 tags: { purpose: "lifecycle-updated" },
79 });
80 }),
81 );
82 const updated = yield* appregistry.getAttributeGroup({
83 attributeGroup: created.attributeGroupId,
84 });
85 expect(updated.id).toBe(created.attributeGroupId);
86 expect(updated.description).toBe("updated description");
87 expect(JSON.parse(updated.attributes ?? "{}")).toEqual({
88 owner: "commerce-team",
89 costCenter: "5678",
90 tier: 1,
91 });
92 expect(updated.tags?.purpose).toBe("lifecycle-updated");
93
94 yield* stack.destroy();
95 yield* assertAttributeGroupGone(created.attributeGroupId);
96 }),
97 {
98 tags: ["provider:aws", "provider:aws:appregistry", "live"],
99 timeout: 180_000,
100 },
101 );