@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, 04:45 UTC

main
ts 82 lines 2.8 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { EventSourcesConfig } from "@alchemy.run/aws/DevOpsGuru/EventSourcesConfig";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as devopsguru from "@distilled.cloud/aws/devops-guru";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 // Observe the account's event sources configuration out-of-band.
11 const observedProfilerStatus = devopsguru
12 .describeEventSourcesConfig({})
13 .pipe(
14 Effect.map(({ EventSources }) => EventSources?.AmazonCodeGuruProfiler?.Status ?? "DISABLED"),
15 );
16
17 // Ungated typed probe: the describe call always answers with the config.
18 test.provider(
19 "describeEventSourcesConfig returns the configuration",
20 () =>
21 Effect.gen(function* () {
22 const status = yield* observedProfilerStatus;
23 expect(["ENABLED", "DISABLED"]).toContain(status);
24 }),
25 { tags: ["provider:aws", "provider:aws:devopsguru", "live"] },
26 );
27
28 // The configuration is an account/region singleton. Only run the destructive
29 // lifecycle when the account is at the default (disabled) — never clobber a
30 // configuration the user already operates.
31 test.provider(
32 "lifecycle: enable CodeGuru Profiler event source, disable, destroy",
33 (stack) =>
34 Effect.gen(function* () {
35 const preexisting = yield* observedProfilerStatus;
36 if (preexisting === "ENABLED") {
37 yield* Effect.logInfo(
38 "CodeGuru Profiler event source already enabled — skipping destructive lifecycle test",
39 );
40 return;
41 }
42
43 yield* stack.destroy();
44
45 // Create — enabled.
46 const created = yield* stack.deploy(
47 Effect.gen(function* () {
48 return yield* EventSourcesConfig("EventSources", {
49 amazonCodeGuruProfiler: true,
50 });
51 }),
52 );
53 expect(created.amazonCodeGuruProfiler).toBe(true);
54 expect(yield* observedProfilerStatus).toBe("ENABLED");
55
56 // Update — back to disabled (converges in place).
57 const updated = yield* stack.deploy(
58 Effect.gen(function* () {
59 return yield* EventSourcesConfig("EventSources", {
60 amazonCodeGuruProfiler: false,
61 });
62 }),
63 );
64 expect(updated.amazonCodeGuruProfiler).toBe(false);
65 expect(yield* observedProfilerStatus).toBe("DISABLED");
66
67 // Re-enable so destroy has something to restore, then destroy.
68 yield* stack.deploy(
69 Effect.gen(function* () {
70 return yield* EventSourcesConfig("EventSources", {
71 amazonCodeGuruProfiler: true,
72 });
73 }),
74 );
75 yield* stack.destroy();
76 expect(yield* observedProfilerStatus).toBe("DISABLED");
77 }),
78 {
79 tags: ["provider:aws", "provider:aws:devopsguru", "live"],
80 timeout: 180_000,
81 },
82 );