@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 32 lines 1.37 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { OrganizationResourcePolicy } from "@alchemy.run/aws/Organizations";
3 import { expect } from "@alchemy.run/test";
4 import * as Provider from "alchemy/Provider";
5 import * as Effect from "effect/Effect";
6 import * as OrganizationLease from "./OrganizationLease.ts";
7
8 const { test } = OrganizationLease.make({ providers: AWS.providers() }, "shared");
9
10 // The org resource policy is a singleton with no list API. `list()` describes
11 // the single resource policy and returns a one-element array if present, else
12 // []. This runs read-only: a missing policy or a non-org account both yield []
13 // via the typed ResourcePolicyNotFoundException / AWSOrganizationsNotInUseException
14 // catches, so the assertion holds without deploying anything.
15 test.provider(
16 "list enumerates the organization resource policy",
17 () =>
18 Effect.gen(function* () {
19 const provider = yield* Provider.findProvider(OrganizationResourcePolicy);
20 const all = yield* provider.list();
21
22 expect(Array.isArray(all)).toBe(true);
23 expect(all.length).toBeLessThanOrEqual(1);
24
25 for (const policy of all) {
26 expect(typeof policy.resourcePolicyId).toBe("string");
27 expect(typeof policy.resourcePolicyArn).toBe("string");
28 expect(policy.document).toBeDefined();
29 }
30 }),
31 { tags: ["provider:aws", "provider:aws:organizations", "live"] },
32 );