1import * as AWS from "@/AWS";
2import { InstanceProfile } from "@/AWS/IAM";
3import * as Provider from "@/Provider";
4import * as Test from "@/Test/Alchemy";
5import * as IAM from "@distilled.cloud/aws/iam";
6import { expect } from "alchemy-test";
7import * as Effect from "effect/Effect";
8
9const { test } = Test.make({ providers: AWS.providers() });
10
11// Canonical `list()` test (IAM is global; account-scoped collection): deploy a
12// real instance profile, resolve the typed provider from context via
13// `findProvider`, call `list()`, and assert the deployed profile appears in the
14// exhaustively-paginated result.
15test.provider(
16 "list enumerates the deployed instance profile",
17 (stack) =>
18 Effect.gen(function* () {
19 yield* stack.destroy();
20
21 const profile = yield* stack.deploy(
22 Effect.gen(function* () {
23 return yield* InstanceProfile("ListProfile", {
24 instanceProfileName: "alchemy-test-instance-profile-list",
25 });
26 }),
27 );
28
29 const provider = yield* Provider.findProvider(InstanceProfile);
30 const all = yield* provider.list();
31
32 expect(
33 all.some((p) => p.instanceProfileName === profile.instanceProfileName),
34 ).toBe(true);
35
36 yield* stack.destroy();
37
38 const deleted = yield* IAM.getInstanceProfile({
39 InstanceProfileName: profile.instanceProfileName,
40 }).pipe(Effect.option);
41 expect(deleted._tag).toBe("None");
42 }),
43 { tags: ["provider:aws", "provider:aws:iam", "live"] },
44);