t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/AWS/CloudWatch/InsightRule.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

55 lines
1.9 KiB
TypeScript

import * as AWS from "@/AWS";
import { InsightRule } from "@/AWS/CloudWatch";
import * as Provider from "@/Provider";
import * as Test from "@/Test/Alchemy";
import { expect } from "alchemy-test";
import * as Effect from "effect/Effect";
const { test } = Test.make({ providers: AWS.providers() });
// list() enumerates every Contributor Insights rule in the account/region via
// `describeInsightRules`. We deploy a real rule, resolve the provider from
// context via the typed `findProvider`, call `list()`, and assert the deployed
// rule appears in the exhaustively paginated result.
test.provider(
"list enumerates the deployed insight rule",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const deployed = yield* stack.deploy(
Effect.gen(function* () {
return yield* InsightRule("ListInsightRule", {
name: "alchemy-test-insight-rule-list",
RuleState: "ENABLED",
RuleDefinition: {
Schema: {
Name: "CloudWatchLogRule",
Version: 1,
},
LogGroupNames: ["alchemy-test-insight-rule-list-log-group"],
LogFormat: "JSON",
Contribution: {
Keys: ["$.ip"],
Filters: [],
},
AggregateOn: "Count",
},
});
}),
);
const provider = yield* Provider.findProvider(InsightRule);
const all = yield* provider.list();
expect(all.some((r) => r.ruleName === deployed.ruleName)).toBe(true);
yield* stack.destroy();
// Out-of-band assert-gone: the exhaustively-paginated live listing no
// longer contains the rule after the final destroy.
const after = yield* provider.list();
expect(after.some((r) => r.ruleName === deployed.ruleName)).toBe(false);
}),
{ tags: ["provider:aws", "provider:aws:cloudwatch", "live"] },
);