1import * as AWS from "@/AWS";
2import { OrganizationResourcePolicy } from "@/AWS/Organizations";
3import * as Provider from "@/Provider";
4import * as Test from "@/Test/Alchemy";
5import { expect } from "alchemy-test";
6import * as Effect from "effect/Effect";
7
8const { test } = Test.make({ providers: AWS.providers() });
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.
15test.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);