t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/AWS/Organizations/Root.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

41 lines
1.7 KiB
TypeScript

import * as AWS from "@/AWS";
import * as Provider from "@/Provider";
import * as Test from "@/Test/Alchemy";
import { expect } from "alchemy-test";
import * as Effect from "effect/Effect";
const { test } = Test.make({ providers: AWS.providers() });
// `Root` is import-only and there is exactly one organization root per
// management account. `list()` enumerates roots via `listRoots` (paginated) and
// hydrates each into the full Attributes shape, or returns `[]` when the account
// isn't an organization management account (the typed
// `AWSOrganizationsNotInUseException` / `AccessDeniedException` are caught to
// `[]`). This runs read-only — it neither creates nor deletes anything.
test.provider(
"list enumerates the organization root",
(stack) =>
Effect.gen(function* () {
const provider = yield* Provider.findProvider(AWS.Organizations.Root);
const all = yield* provider.list();
// 0 (account is not a management account) or 1 (it is) — never more.
expect(all.length).toBeLessThanOrEqual(1);
// When the account is an organization management account, the single entry
// carries a well-typed Attributes shape.
if (all.length === 1) {
const root = all[0];
expect(typeof root.rootId).toBe("string");
expect(root.rootId.length).toBeGreaterThan(0);
expect(typeof root.rootArn).toBe("string");
expect(root.rootArn.startsWith("arn:aws:organizations::")).toBe(true);
expect(typeof root.rootName).toBe("string");
expect(Array.isArray(root.policyTypes)).toBe(true);
expect(typeof root.tags).toBe("object");
}
yield* stack.destroy();
}),
{ tags: ["provider:aws", "provider:aws:organizations", "live"] },
);