@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 56 lines 1.89 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Alarm } from "@alchemy.run/aws/CloudWatch/Alarm";
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 real
12 // CloudWatch metric alarm, resolve the provider from context via the typed
13 // `findProvider` helper, call `list()`, and assert the deployed alarm appears in
14 // the exhaustively-paginated `describeAlarms` result (filtered to MetricAlarm).
15 test.provider(
16 "list enumerates the deployed alarm",
17 (stack) =>
18 Effect.gen(function* () {
19 yield* stack.destroy();
20
21 const alarm = yield* stack.deploy(
22 Effect.gen(function* () {
23 return yield* Alarm("ListAlarm", {
24 MetricName: "Errors",
25 Namespace: "AWS/Lambda",
26 Statistic: "Sum",
27 Period: 60,
28 EvaluationPeriods: 1,
29 Threshold: 1,
30 ComparisonOperator: "GreaterThanOrEqualToThreshold",
31 });
32 }),
33 );
34
35 expect(alarm.alarmArn).toBeDefined();
36
37 const provider = yield* Provider.findProvider(Alarm);
38 const all = yield* provider.list();
39
40 expect(all.some((a) => a.alarmArn === alarm.alarmArn)).toBe(true);
41
42 yield* stack.destroy();
43
44 // Out-of-band assert-gone: describeAlarms by name returns an empty
45 // collection once the alarm is deleted.
46 const gone = yield* cloudwatch.describeAlarms({
47 AlarmNames: [alarm.alarmName],
48 AlarmTypes: ["MetricAlarm"],
49 });
50 expect(gone.MetricAlarms ?? []).toEqual([]);
51 }),
52 {
53 tags: ["provider:aws", "provider:aws:cloudwatch", "live"],
54 timeout: 120_000,
55 },
56 );