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

main
ts 55 lines 1.94 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { InsightRule } 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 Contributor Insights rule in the account/region via
11 // `describeInsightRules`. We deploy a real rule, resolve the provider from
12 // context via the typed `findProvider`, call `list()`, and assert the deployed
13 // rule appears in the exhaustively paginated result.
14 test.provider(
15 "list enumerates the deployed insight rule",
16 (stack) =>
17 Effect.gen(function* () {
18 yield* stack.destroy();
19
20 const deployed = yield* stack.deploy(
21 Effect.gen(function* () {
22 return yield* InsightRule("ListInsightRule", {
23 name: "alchemy-test-insight-rule-list",
24 RuleState: "ENABLED",
25 RuleDefinition: {
26 Schema: {
27 Name: "CloudWatchLogRule",
28 Version: 1,
29 },
30 LogGroupNames: ["alchemy-test-insight-rule-list-log-group"],
31 LogFormat: "JSON",
32 Contribution: {
33 Keys: ["$.ip"],
34 Filters: [],
35 },
36 AggregateOn: "Count",
37 },
38 });
39 }),
40 );
41
42 const provider = yield* Provider.findProvider(InsightRule);
43 const all = yield* provider.list();
44
45 expect(all.some((r) => r.ruleName === deployed.ruleName)).toBe(true);
46
47 yield* stack.destroy();
48
49 // Out-of-band assert-gone: the exhaustively-paginated live listing no
50 // longer contains the rule after the final destroy.
51 const after = yield* provider.list();
52 expect(after.some((r) => r.ruleName === deployed.ruleName)).toBe(false);
53 }),
54 { tags: ["provider:aws", "provider:aws:cloudwatch", "live"] },
55 );