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 { ScheduleGroup } from "@alchemy.run/aws/Scheduler"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Provider from "alchemy/Provider"; |
| 5 | import * as Data from "effect/Data"; |
| 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 | class ScheduleGroupNotListed extends Data.TaggedError("ScheduleGroupNotListed") {} |
| 12 | |
| 13 | test.provider( |
| 14 | "list enumerates the deployed schedule group", |
| 15 | (stack) => |
| 16 | Effect.gen(function* () { |
| 17 | yield* stack.destroy(); |
| 18 | |
| 19 | const deployed = yield* stack.deploy( |
| 20 | Effect.gen(function* () { |
| 21 | return yield* ScheduleGroup("ListScheduleGroup", {}); |
| 22 | }), |
| 23 | ); |
| 24 | |
| 25 | const provider = yield* Provider.findProvider(ScheduleGroup); |
| 26 | |
| 27 | // EventBridge Scheduler is eventually consistent: a freshly-created group |
| 28 | // may not appear in listScheduleGroups immediately. Retry the list |
| 29 | // assertion on a bounded schedule. |
| 30 | yield* Effect.gen(function* () { |
| 31 | const all = yield* provider.list(); |
| 32 | if (!all.some((g) => g.scheduleGroupArn === deployed.scheduleGroupArn)) { |
| 33 | return yield* Effect.fail(new ScheduleGroupNotListed()); |
| 34 | } |
| 35 | }).pipe( |
| 36 | Effect.retry({ |
| 37 | while: (e) => e._tag === "ScheduleGroupNotListed", |
| 38 | schedule: Schedule.max([Schedule.fixed("3 seconds"), Schedule.recurs(20)]), |
| 39 | }), |
| 40 | ); |
| 41 | |
| 42 | yield* stack.destroy(); |
| 43 | }), |
| 44 | { |
| 45 | tags: ["provider:aws", "provider:aws:scheduler", "live"], |
| 46 | timeout: 120_000, |
| 47 | }, |
| 48 | ); |