The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { NetworkAcl, NetworkAclAssociation, Subnet } from "@alchemy.run/aws/EC2"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 5 | import * as Provider from "alchemy/Provider"; |
| 6 | import * as Data from "effect/Data"; |
| 7 | import * as Effect from "effect/Effect"; |
| 8 | import { MinimumLogLevel } from "effect/References"; |
| 9 | import * as Schedule from "effect/Schedule"; |
| 10 | import { getDefaultVpc } from "../DefaultVpc.ts"; |
| 11 | import { assertNetworkAclGone, assertSubnetGone } from "./Gone.ts"; |
| 12 | |
| 13 | const { test } = Test.make({ providers: AWS.providers() }); |
| 14 | |
| 15 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 16 | |
| 17 | class NetworkAclAssociationNotListed extends Data.TaggedError( |
| 18 | "NetworkAclAssociationNotListed", |
| 19 | )<{}> {} |
| 20 | |
| 21 | test.provider( |
| 22 | "list enumerates the deployed NetworkAclAssociation", |
| 23 | (stack) => |
| 24 | Effect.gen(function* () { |
| 25 | yield* stack.destroy(); |
| 26 | |
| 27 | const defaultVpc = yield* getDefaultVpc; |
| 28 | const { subnet, acl, assoc } = yield* stack.deploy( |
| 29 | Effect.gen(function* () { |
| 30 | const subnet = yield* Subnet("ListNaclAssocSubnet", { |
| 31 | vpcId: defaultVpc.vpcId, |
| 32 | cidrBlock: defaultVpc.subnetCidrBlock(221), |
| 33 | }); |
| 34 | const acl = yield* NetworkAcl("ListNaclAssocAcl", { vpcId: defaultVpc.vpcId }); |
| 35 | const assoc = yield* NetworkAclAssociation("ListNaclAssoc", { |
| 36 | networkAclId: acl.networkAclId, |
| 37 | subnetId: subnet.subnetId, |
| 38 | }); |
| 39 | return { subnet, acl, assoc }; |
| 40 | }), |
| 41 | ); |
| 42 | |
| 43 | const provider = yield* Provider.findProvider(NetworkAclAssociation); |
| 44 | const all = yield* provider.list().pipe( |
| 45 | Effect.flatMap((all) => |
| 46 | all.some((x) => x.associationId === assoc.associationId) |
| 47 | ? Effect.succeed(all) |
| 48 | : Effect.fail(new NetworkAclAssociationNotListed()), |
| 49 | ), |
| 50 | Effect.retry({ |
| 51 | while: (e) => e._tag === "NetworkAclAssociationNotListed", |
| 52 | schedule: Schedule.max([Schedule.spaced("3 seconds"), Schedule.recurs(10)]), |
| 53 | }), |
| 54 | ); |
| 55 | |
| 56 | expect(all.some((x) => x.associationId === assoc.associationId)).toBe(true); |
| 57 | |
| 58 | yield* stack.destroy(); |
| 59 | |
| 60 | // The default VPC is shared/standing — assert the resources this test |
| 61 | // created inside it (subnet + ACL, whose deletion also proves the |
| 62 | // association was released) are gone. |
| 63 | yield* assertNetworkAclGone(acl.networkAclId); |
| 64 | yield* assertSubnetGone(subnet.subnetId); |
| 65 | }).pipe(logLevel), |
| 66 | { tags: ["provider:aws", "provider:aws:ec2", "live"] }, |
| 67 | ); |