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

main
ts 57 lines 1.97 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Dashboard } from "@alchemy.run/aws/CloudWatch/Dashboard";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as cloudwatch from "@distilled.cloud/aws/cloudwatch";
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 // Canonical `list()` test (AWS account/region-scoped collection): deploy a
12 // real dashboard, resolve the provider from context via `findProvider`, call
13 // `list()`, and assert the deployed dashboard appears in the exhaustively-
14 // paginated result.
15 test.provider(
16 "list enumerates the deployed dashboard",
17 (stack) =>
18 Effect.gen(function* () {
19 yield* stack.destroy();
20
21 const dashboard = yield* stack.deploy(
22 Effect.gen(function* () {
23 return yield* Dashboard("ListDashboard", {
24 name: "alchemy-test-dashboard-list",
25 DashboardBody: {
26 widgets: [
27 {
28 type: "text",
29 x: 0,
30 y: 0,
31 width: 6,
32 height: 3,
33 properties: { markdown: "# list test" },
34 },
35 ],
36 },
37 });
38 }),
39 );
40
41 const provider = yield* Provider.findProvider(Dashboard);
42 const all = yield* provider.list();
43
44 expect(all.some((d) => d.dashboardName === dashboard.dashboardName)).toBe(true);
45
46 yield* stack.destroy();
47
48 // Out-of-band assert-gone: getDashboard returns the typed
49 // DashboardNotFoundError once the dashboard is deleted.
50 const gone = yield* cloudwatch.getDashboard({ DashboardName: dashboard.dashboardName }).pipe(
51 Effect.map(() => false),
52 Effect.catchTag("DashboardNotFoundError", () => Effect.succeed(true)),
53 );
54 expect(gone).toBe(true);
55 }),
56 { tags: ["provider:aws", "provider:aws:cloudwatch", "live"] },
57 );