1import * as AWS from "@/AWS";
2import { User } 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
11test.provider(
12 "list enumerates the deployed user",
13 (stack) =>
14 Effect.gen(function* () {
15 yield* stack.destroy();
16
17 const user = yield* stack.deploy(
18 Effect.gen(function* () {
19 return yield* User("ListUser", {
20 tags: {
21 env: "test",
22 },
23 });
24 }),
25 );
26
27 const provider = yield* Provider.findProvider(User);
28 const all = yield* provider.list();
29
30 const found = all.find((u) => u.userName === user.userName);
31 expect(found).toBeDefined();
32 expect(found?.userArn).toBe(user.userArn);
33
34 yield* stack.destroy();
35
36 const deleted = yield* IAM.getUser({
37 UserName: user.userName,
38 }).pipe(Effect.option);
39 expect(deleted._tag).toBe("None");
40 }),
41 { tags: ["provider:aws", "provider:aws:iam", "live"] },
42);