@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 63 lines 2.61 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Instance } from "@alchemy.run/aws/IdentityCenter";
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 // An IAM Identity Center instance is a pre-existing account/organization
11 // singleton — you generally cannot create one inside a test. `list()`
12 // enumerates every visible instance via `ListInstances` and returns the
13 // exact `read` Attributes shape. Accounts without SSO enabled return `[]`
14 // (not an error), so this test asserts a well-typed `Attributes[]` and
15 // validates the element shape only when at least one instance exists.
16 test.provider(
17 "list enumerates visible Identity Center instances",
18 () =>
19 Effect.gen(function* () {
20 const provider = yield* Provider.findProvider(Instance);
21 const all = yield* provider.list();
22
23 expect(Array.isArray(all)).toBe(true);
24
25 for (const instance of all) {
26 expect(typeof instance.instanceArn).toBe("string");
27 expect(instance.instanceArn.length).toBeGreaterThan(0);
28 expect(typeof instance.identityStoreId).toBe("string");
29 expect(instance.identityStoreId.length).toBeGreaterThan(0);
30 expect(instance.mode).toBe("existing");
31 }
32 }),
33 { tags: ["provider:aws", "provider:aws:identitycenter", "live"] },
34 );
35
36 // `instanceArn` and `name` only select which instance to adopt, so adding,
37 // removing, or pinning one that matches the adopted instance plans an update. A
38 // replace in `account` mode would delete the instance it just re-adopted.
39 // Needs an enabled instance, so it is gated like the rest of this service.
40 test.provider.skipIf(!process.env.ALCHEMY_TEST_IDENTITY_CENTER)(
41 "pinning or dropping the lookup arn of the adopted instance updates in place",
42 (stack) =>
43 Effect.gen(function* () {
44 yield* stack.destroy();
45
46 const instance = yield* stack.deploy(Instance("IdentityCenter", { mode: "existing" }));
47
48 const pinned = yield* stack.plan(
49 Instance("IdentityCenter", { instanceArn: instance.instanceArn }),
50 );
51 expect(pinned.resources.IdentityCenter?.action).toBe("update");
52
53 yield* stack.deploy(
54 Instance("IdentityCenter", { instanceArn: instance.instanceArn, mode: "existing" }),
55 );
56
57 const dropped = yield* stack.plan(Instance("IdentityCenter", {}));
58 expect(dropped.resources.IdentityCenter?.action).toBe("update");
59
60 yield* stack.destroy();
61 }),
62 { tags: ["provider:aws", "provider:aws:identitycenter", "live"] },
63 );