The best way to control Claude Code, Codex and more from any computer or phone

main
ts 48 lines 1.79 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Schedule } from "@alchemy.run/aws/DataBrew";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as databrew from "@distilled.cloud/aws/databrew";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 const getSchedule = (name: string) =>
11 databrew
12 .describeSchedule({ Name: name })
13 .pipe(Effect.catchTag("ResourceNotFoundException", () => Effect.succeed(undefined)));
14
15 const withSchedule = (cronExpression: string) =>
16 Effect.gen(function* () {
17 const schedule = yield* Schedule("Nightly", {
18 cronExpression,
19 tags: { Environment: "test" },
20 });
21 return { schedule };
22 });
23
24 test.provider(
25 "create, update, delete a schedule",
26 (stack) =>
27 Effect.gen(function* () {
28 yield* stack.destroy();
29
30 const created = yield* stack.deploy(withSchedule("cron(0 3 * * ? *)"));
31 expect(created.schedule.scheduleArn).toContain(`:schedule/${created.schedule.scheduleName}`);
32
33 // out-of-band verification
34 const observed = yield* getSchedule(created.schedule.scheduleName);
35 expect(observed?.CronExpression).toEqual("cron(0 3 * * ? *)");
36 expect(observed?.Tags?.["alchemy::id"]).toBeDefined();
37 expect(observed?.Tags?.Environment).toEqual("test");
38
39 // update: new cron expression (same logical resource)
40 yield* stack.deploy(withSchedule("cron(30 4 * * ? *)"));
41 const updated = yield* getSchedule(created.schedule.scheduleName);
42 expect(updated?.CronExpression).toEqual("cron(30 4 * * ? *)");
43
44 yield* stack.destroy();
45 expect(yield* getSchedule(created.schedule.scheduleName)).toBeUndefined();
46 }),
47 { tags: ["provider:aws", "provider:aws:databrew", "live"], timeout: 120_000 },
48 );