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 { InternetGateway, Route, RouteTable, Vpc } from "@alchemy.run/aws/EC2"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Provider from "alchemy/Provider"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { MinimumLogLevel } from "effect/References"; |
| 7 | import { assertRouteTableGone, assertVpcGone } from "./Gone.ts"; |
| 8 | import * as Test from "./VpcTest.ts"; |
| 9 | |
| 10 | const { test } = Test.make({ providers: AWS.providers() }); |
| 11 | |
| 12 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 13 | |
| 14 | test.provider( |
| 15 | "list enumerates the deployed Route", |
| 16 | (stack) => |
| 17 | Effect.gen(function* () { |
| 18 | yield* stack.destroy(); |
| 19 | |
| 20 | const deployed = yield* stack.deploy( |
| 21 | Effect.gen(function* () { |
| 22 | const vpc = yield* Vpc("ListRouteVpc", { |
| 23 | cidrBlock: "10.0.0.0/16", |
| 24 | }); |
| 25 | const igw = yield* InternetGateway("ListRouteIgw", { |
| 26 | vpcId: vpc.vpcId, |
| 27 | }); |
| 28 | const routeTable = yield* RouteTable("ListRouteTable", { |
| 29 | vpcId: vpc.vpcId, |
| 30 | }); |
| 31 | const route = yield* Route("ListRoute", { |
| 32 | routeTableId: routeTable.routeTableId, |
| 33 | destinationCidrBlock: "0.0.0.0/0", |
| 34 | gatewayId: igw.internetGatewayId, |
| 35 | }); |
| 36 | return { vpc, routeTable, route }; |
| 37 | }), |
| 38 | ); |
| 39 | |
| 40 | const provider = yield* Provider.findProvider(Route); |
| 41 | const all = yield* provider.list(); |
| 42 | |
| 43 | expect( |
| 44 | all.some( |
| 45 | (x) => |
| 46 | x.routeTableId === deployed.route.routeTableId && |
| 47 | x.destinationCidrBlock === deployed.route.destinationCidrBlock && |
| 48 | x.gatewayId === deployed.route.gatewayId, |
| 49 | ), |
| 50 | ).toBe(true); |
| 51 | |
| 52 | yield* stack.destroy(); |
| 53 | |
| 54 | // A route has no standalone id — its route table (and the whole VPC) |
| 55 | // being gone proves the route was torn down. |
| 56 | yield* assertRouteTableGone(deployed.routeTable.routeTableId); |
| 57 | yield* assertVpcGone(deployed.vpc.vpcId); |
| 58 | }).pipe(logLevel), |
| 59 | { tags: ["provider:aws", "provider:aws:ec2", "live"] }, |
| 60 | ); |