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 { Space } from "@alchemy.run/aws/RePostSpace"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 5 | import * as repostspace from "@distilled.cloud/aws/repostspace"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | import * as Schedule from "effect/Schedule"; |
| 8 | |
| 9 | const { test } = Test.make({ providers: AWS.providers() }); |
| 10 | |
| 11 | // Ungated typed-error probe: prove the distilled error union carries the |
| 12 | // not-found tag this provider's read/reconcile/delete paths depend on. Runs |
| 13 | // in every CI pass at near-zero cost, unlike the gated lifecycle below. |
| 14 | test.provider( |
| 15 | "getSpace on a nonexistent space fails with ResourceNotFoundException", |
| 16 | () => |
| 17 | Effect.gen(function* () { |
| 18 | const error = yield* Effect.flip( |
| 19 | repostspace.getSpace({ spaceId: "SPalchemynonexistentprobe0" }), |
| 20 | ); |
| 21 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 22 | }), |
| 23 | { tags: ["provider:aws", "provider:aws:repostspace", "live"] }, |
| 24 | ); |
| 25 | |
| 26 | // Deletion is verified as INITIATED (a DELETE* status, irreversible) or |
| 27 | // fully gone. Full disappearance takes several more minutes server-side. |
| 28 | const assertSpaceDeleting = (spaceId: string) => |
| 29 | Effect.gen(function* () { |
| 30 | const status = yield* repostspace.getSpace({ spaceId }).pipe( |
| 31 | Effect.map((space) => space.status), |
| 32 | Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("gone" as const)), |
| 33 | ); |
| 34 | if (status !== "gone" && !status.startsWith("DELETE")) { |
| 35 | return yield* Effect.fail(new Error(`space '${spaceId}' still exists (status: ${status})`)); |
| 36 | } |
| 37 | }).pipe( |
| 38 | Effect.retry({ schedule: Schedule.max([Schedule.fixed("10 seconds"), Schedule.recurs(18)]) }), |
| 39 | ); |
| 40 | |
| 41 | // re:Post Private is a paid tier (Basic/Standard) that requires IAM Identity |
| 42 | // Center and provisions asynchronously (~30 minutes). The full lifecycle is |
| 43 | // gated behind AWS_TEST_REPOSTSPACE=1 and always destroys what it created. |
| 44 | test.provider.skipIf(!process.env.AWS_TEST_REPOSTSPACE)( |
| 45 | "create re:Post Private space (BASIC), update description, destroy", |
| 46 | (stack) => |
| 47 | Effect.gen(function* () { |
| 48 | yield* stack.destroy(); |
| 49 | |
| 50 | const make = (description: string) => |
| 51 | Effect.gen(function* () { |
| 52 | const space = yield* Space("Space", { |
| 53 | // subdomain must be globally unique across re:Post Private — |
| 54 | // deterministic, alchemy-branded constant. |
| 55 | subdomain: "alchemy-e2e-repost-space", |
| 56 | tier: "BASIC", |
| 57 | description, |
| 58 | tags: { fixture: "repostspace-space" }, |
| 59 | }); |
| 60 | return { space }; |
| 61 | }); |
| 62 | |
| 63 | const { space } = yield* stack.deploy(make("alchemy repostspace test")); |
| 64 | |
| 65 | expect(space.spaceId).toBeDefined(); |
| 66 | expect(space.spaceArn).toContain(":space/"); |
| 67 | expect(space.status).toBe("CREATE_COMPLETED"); |
| 68 | expect(space.tier).toBe("BASIC"); |
| 69 | expect(space.randomDomain).toBeDefined(); |
| 70 | expect(space.description).toBe("alchemy repostspace test"); |
| 71 | |
| 72 | // Out-of-band verification via distilled. |
| 73 | const observed = yield* repostspace.getSpace({ spaceId: space.spaceId }); |
| 74 | expect(observed.status).toBe("CREATE_COMPLETED"); |
| 75 | expect(observed.tier).toBe("BASIC"); |
| 76 | |
| 77 | // In-place update (no replacement): description changes, id is stable. |
| 78 | const { space: updated } = yield* stack.deploy(make("alchemy repostspace test (updated)")); |
| 79 | expect(updated.spaceId).toBe(space.spaceId); |
| 80 | expect(updated.description).toBe("alchemy repostspace test (updated)"); |
| 81 | |
| 82 | // Destroy immediately — spaces bill while they exist — and verify |
| 83 | // deletion was initiated out-of-band. |
| 84 | yield* stack.destroy(); |
| 85 | yield* assertSpaceDeleting(space.spaceId); |
| 86 | }), |
| 87 | // async provisioning (~30 min) + update + delete initiation, one test. |
| 88 | { tags: ["provider:aws", "provider:aws:repostspace", "live"], timeout: 3_600_000 }, |
| 89 | ); |