1import * as AWS from "@/AWS";
2import { AccountAlias } from "@/AWS/IAM/AccountAlias.ts";
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// Canonical `list()` test (account singleton): an AWS account has at most one
11// alias, so `list()` returns a one-element array (the single alias) or `[]`.
12//
13// Setting/deleting the account alias is account-wide and disruptive — it would
14// clobber whatever alias the account already has — so this is an UNGATED probe
15// that only observes: it calls `list()` and asserts a well-formed result
16// (length 0 or 1, with the full `{ accountAlias }` Attributes shape when set).
17test.provider(
18 "list enumerates the account alias singleton",
19 () =>
20 Effect.gen(function* () {
21 const provider = yield* Provider.findProvider(AccountAlias);
22 const all = yield* provider.list();
23
24 expect(Array.isArray(all)).toBe(true);
25 expect(all.length).toBeLessThanOrEqual(1);
26 for (const item of all) {
27 expect(typeof item.accountAlias).toBe("string");
28 expect(item.accountAlias.length).toBeGreaterThan(0);
29 }
30 }),
31 { tags: ["provider:aws", "provider:aws:iam", "live"] },
32);