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, 04:45 UTC
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { ReportGroup } from "@alchemy.run/aws/CodeBuild/ReportGroup"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 5 | import * as codebuild from "@distilled.cloud/aws/codebuild"; |
| 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 | const reportGroupName = "alchemy-test-codebuild-report-group"; |
| 12 | |
| 13 | /** Find the group's ARN by name (report groups are addressed by ARN). */ |
| 14 | const findReportGroupArn = codebuild |
| 15 | .listReportGroups({}) |
| 16 | .pipe( |
| 17 | Effect.map((res) => |
| 18 | res.reportGroups?.find((arn) => arn.endsWith(`report-group/${reportGroupName}`)), |
| 19 | ), |
| 20 | ); |
| 21 | |
| 22 | const getReportGroup = Effect.gen(function* () { |
| 23 | const arn = yield* findReportGroupArn; |
| 24 | if (arn === undefined) return undefined; |
| 25 | const res = yield* codebuild.batchGetReportGroups({ |
| 26 | reportGroupArns: [arn], |
| 27 | }); |
| 28 | const group = res.reportGroups?.[0]; |
| 29 | return group?.status === "DELETING" ? undefined : group; |
| 30 | }); |
| 31 | |
| 32 | test.provider( |
| 33 | "lifecycle: create TEST report group, update tags, destroy", |
| 34 | (stack) => |
| 35 | Effect.gen(function* () { |
| 36 | yield* stack.destroy(); |
| 37 | |
| 38 | // Create — a TEST report group with the default NO_EXPORT config. |
| 39 | const deployed = yield* stack.deploy( |
| 40 | ReportGroup("LifecycleReportGroup", { |
| 41 | reportGroupName, |
| 42 | type: "TEST", |
| 43 | }), |
| 44 | ); |
| 45 | expect(deployed.reportGroupArn).toContain(`report-group/${reportGroupName}`); |
| 46 | expect(deployed.reportGroupName).toBe(reportGroupName); |
| 47 | |
| 48 | // Out-of-band verification via distilled. |
| 49 | const created = yield* getReportGroup; |
| 50 | expect(created?.name).toBe(reportGroupName); |
| 51 | expect(created?.type).toBe("TEST"); |
| 52 | expect(created?.exportConfig?.exportConfigType).toBe("NO_EXPORT"); |
| 53 | |
| 54 | // Canonical list() coverage. |
| 55 | const provider = yield* Provider.findProvider(ReportGroup); |
| 56 | const all = yield* provider.list(); |
| 57 | expect(all.some((g) => g.reportGroupName === reportGroupName)).toBe(true); |
| 58 | |
| 59 | // Update — add a user tag in place (no replacement). |
| 60 | yield* stack.deploy( |
| 61 | ReportGroup("LifecycleReportGroup", { |
| 62 | reportGroupName, |
| 63 | type: "TEST", |
| 64 | tags: { Purpose: "alchemy-test" }, |
| 65 | }), |
| 66 | ); |
| 67 | const updated = yield* getReportGroup; |
| 68 | expect(updated?.tags?.find((t) => t.key === "Purpose")?.value).toBe("alchemy-test"); |
| 69 | |
| 70 | // Re-deploy identical props — sync diff is a no-op that converges. |
| 71 | yield* stack.deploy( |
| 72 | ReportGroup("LifecycleReportGroup", { |
| 73 | reportGroupName, |
| 74 | type: "TEST", |
| 75 | tags: { Purpose: "alchemy-test" }, |
| 76 | }), |
| 77 | ); |
| 78 | |
| 79 | // Destroy — the group is deleted; verify it is gone out-of-band. |
| 80 | yield* stack.destroy(); |
| 81 | const after = yield* getReportGroup; |
| 82 | expect(after).toBeUndefined(); |
| 83 | }), |
| 84 | { |
| 85 | tags: ["provider:aws", "provider:aws:codebuild", "live"], |
| 86 | timeout: 120_000, |
| 87 | }, |
| 88 | ); |