t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/AWS/Scheduler/ScheduleGroup.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

55 lines
1.6 KiB
TypeScript

import * as AWS from "@/AWS";
import { ScheduleGroup } from "@/AWS/Scheduler";
import * as Provider from "@/Provider";
import * as Test from "@/Test/Alchemy";
import * as Data from "effect/Data";
import * as Effect from "effect/Effect";
import * as Schedule from "effect/Schedule";
const { test } = Test.make({ providers: AWS.providers() });
class ScheduleGroupNotListed extends Data.TaggedError(
"ScheduleGroupNotListed",
) {}
test.provider(
"list enumerates the deployed schedule group",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const deployed = yield* stack.deploy(
Effect.gen(function* () {
return yield* ScheduleGroup("ListScheduleGroup", {});
}),
);
const provider = yield* Provider.findProvider(ScheduleGroup);
// EventBridge Scheduler is eventually consistent: a freshly-created group
// may not appear in listScheduleGroups immediately. Retry the list
// assertion on a bounded schedule.
yield* Effect.gen(function* () {
const all = yield* provider.list();
if (
!all.some((g) => g.scheduleGroupArn === deployed.scheduleGroupArn)
) {
return yield* Effect.fail(new ScheduleGroupNotListed());
}
}).pipe(
Effect.retry({
while: (e) => e._tag === "ScheduleGroupNotListed",
schedule: Schedule.max([
Schedule.fixed("3 seconds"),
Schedule.recurs(20),
]),
}),
);
yield* stack.destroy();
}),
{
tags: ["provider:aws", "provider:aws:scheduler", "live"],
timeout: 120_000,
},
);