The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { InstanceProfile } from "@alchemy.run/aws/IAM"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 5 | import * as IAM from "@distilled.cloud/aws/iam"; |
| 6 | import * as Provider from "alchemy/Provider"; |
| 7 | import * as Effect from "effect/Effect"; |
| 8 | |
| 9 | const { 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. |
| 15 | test.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(all.some((p) => p.instanceProfileName === profile.instanceProfileName)).toBe(true); |
| 33 | |
| 34 | yield* stack.destroy(); |
| 35 | |
| 36 | const deleted = yield* IAM.getInstanceProfile({ |
| 37 | InstanceProfileName: profile.instanceProfileName, |
| 38 | }).pipe(Effect.option); |
| 39 | expect(deleted._tag).toBe("None"); |
| 40 | }), |
| 41 | { tags: ["provider:aws", "provider:aws:iam", "live"] }, |
| 42 | ); |