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

main
ts 49 lines 1.73 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { KeyValueStore } from "@alchemy.run/aws/CloudFront";
3 import { describe, expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as cloudfront from "@distilled.cloud/aws/cloudfront";
6 import * as Provider from "alchemy/Provider";
7 import * as Effect from "effect/Effect";
8 import * as Schedule from "effect/Schedule";
9
10 const { test } = Test.make({ providers: AWS.providers() });
11
12 describe(
13 "AWS.CloudFront.KeyValueStore",
14 { tags: ["provider:aws", "provider:aws:cloudfront", "live"] },
15 () => {
16 test.provider(
17 "list enumerates the deployed key value store",
18 (stack) =>
19 Effect.gen(function* () {
20 yield* stack.destroy();
21
22 const deployed = yield* stack.deploy(
23 Effect.gen(function* () {
24 return yield* KeyValueStore("ListKeyValueStore", { comment: "list" });
25 }),
26 );
27
28 const provider = yield* Provider.findProvider(KeyValueStore);
29 const all = yield* provider.list();
30
31 expect(all.some((s) => s.keyValueStoreId === deployed.keyValueStoreId)).toBe(true);
32
33 yield* stack.destroy();
34 yield* assertKeyValueStoreDeleted(deployed.keyValueStoreName);
35 }),
36 { timeout: 300_000 },
37 );
38 },
39 );
40
41 const assertKeyValueStoreDeleted = (name: string) =>
42 cloudfront.describeKeyValueStore({ Name: name }).pipe(
43 Effect.flatMap(() => Effect.fail(new Error("KeyValueStoreStillExists"))),
44 Effect.catchTag("EntityNotFound", () => Effect.void),
45 Effect.retry({
46 while: (error) => error instanceof Error && error.message === "KeyValueStoreStillExists",
47 schedule: Schedule.max([Schedule.fixed("5 seconds"), Schedule.recurs(24)]),
48 }),
49 );