@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 96 lines 3.23 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Group, UserPool } from "@alchemy.run/aws/Cognito";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as cip from "@distilled.cloud/aws/cognito-identity-provider";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 test.provider(
11 "create, update, rename (replace), delete group",
12 (stack) =>
13 Effect.gen(function* () {
14 yield* stack.destroy();
15
16 const outputs = yield* stack.deploy(
17 Effect.gen(function* () {
18 const pool = yield* UserPool("GroupTestPool", {});
19 const group = yield* Group("Team", {
20 userPoolId: pool.userPoolId,
21 description: "first description",
22 precedence: 5,
23 });
24 return { pool, group };
25 }),
26 );
27
28 expect(outputs.group.groupName).toBeDefined();
29
30 // out-of-band verification via distilled
31 const created = yield* cip.getGroup({
32 UserPoolId: outputs.pool.userPoolId,
33 GroupName: outputs.group.groupName,
34 });
35 expect(created.Group?.Description).toBe("first description");
36 expect(created.Group?.Precedence).toBe(5);
37
38 // description/precedence mutate in place
39 const updated = yield* stack.deploy(
40 Effect.gen(function* () {
41 const pool = yield* UserPool("GroupTestPool", {});
42 const group = yield* Group("Team", {
43 userPoolId: pool.userPoolId,
44 description: "second description",
45 precedence: 7,
46 });
47 return { pool, group };
48 }),
49 );
50 expect(updated.group.groupName).toBe(outputs.group.groupName);
51 const afterUpdate = yield* cip.getGroup({
52 UserPoolId: outputs.pool.userPoolId,
53 GroupName: outputs.group.groupName,
54 });
55 expect(afterUpdate.Group?.Description).toBe("second description");
56 expect(afterUpdate.Group?.Precedence).toBe(7);
57
58 // renaming replaces the group
59 const renamed = yield* stack.deploy(
60 Effect.gen(function* () {
61 const pool = yield* UserPool("GroupTestPool", {});
62 const group = yield* Group("Team", {
63 userPoolId: pool.userPoolId,
64 groupName: "explicit-team-name",
65 description: "second description",
66 precedence: 7,
67 });
68 return { pool, group };
69 }),
70 );
71 expect(renamed.group.groupName).toBe("explicit-team-name");
72 const oldGone = yield* cip
73 .getGroup({
74 UserPoolId: outputs.pool.userPoolId,
75 GroupName: outputs.group.groupName,
76 })
77 .pipe(
78 Effect.map(() => false),
79 Effect.catchTag("ResourceNotFoundException", () => Effect.succeed(true)),
80 );
81 expect(oldGone).toBe(true);
82
83 yield* stack.destroy();
84 const gone = yield* cip
85 .getGroup({
86 UserPoolId: outputs.pool.userPoolId,
87 GroupName: "explicit-team-name",
88 })
89 .pipe(
90 Effect.map(() => false),
91 Effect.catchTag("ResourceNotFoundException", () => Effect.succeed(true)),
92 );
93 expect(gone).toBe(true);
94 }),
95 { tags: ["provider:aws", "provider:aws:cognito", "live"], timeout: 120_000 },
96 );