@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 48 lines 1.8 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { AnomalyDetector } from "@alchemy.run/aws/CloudWatch";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as Provider from "alchemy/Provider";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 // `list()` enumerates every CloudWatch anomaly detector in the account/region
11 // via the paginated `cloudwatch.describeAnomalyDetectors` op. Deploy a real
12 // single-metric detector, resolve the provider from context via the typed
13 // `findProvider`, call `list()`, and assert the deployed detector appears in the
14 // exhaustively paginated result (matched by its stable `detectorId` identity).
15 test.provider(
16 "list enumerates the deployed anomaly detector",
17 (stack) =>
18 Effect.gen(function* () {
19 yield* stack.destroy();
20
21 const detector = yield* stack.deploy(
22 Effect.gen(function* () {
23 return yield* AnomalyDetector("ListAnomalyDetector", {
24 Namespace: "AWS/Lambda",
25 MetricName: "Errors",
26 Stat: "Sum",
27 Dimensions: [{ Name: "FunctionName", Value: "alchemy-test-anomaly-list" }],
28 });
29 }),
30 );
31
32 const provider = yield* Provider.findProvider(AnomalyDetector);
33 const all = yield* provider.list();
34
35 expect(all.some((d) => d.detectorId === detector.detectorId)).toBe(true);
36
37 yield* stack.destroy();
38
39 // Out-of-band assert-gone: the exhaustively-paginated live listing no
40 // longer contains the detector after the final destroy.
41 const after = yield* provider.list();
42 expect(after.some((d) => d.detectorId === detector.detectorId)).toBe(false);
43 }),
44 {
45 tags: ["provider:aws", "provider:aws:cloudwatch", "live"],
46 timeout: 240_000,
47 },
48 );