@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 89 lines 3.3 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Discovery, GroupingConfiguration } from "@alchemy.run/aws/ApplicationSignals";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as appsignals from "@distilled.cloud/aws/application-signals";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 const observedDefinitions = appsignals
11 .listGroupingAttributeDefinitions({})
12 .pipe(Effect.map((r) => r.GroupingAttributeDefinitions));
13
14 // The grouping configuration is an ACCOUNT-LEVEL singleton: this test owns
15 // it for the duration of the run (create → update → delete restores the
16 // account to its unconfigured default).
17 test.provider(
18 "create, update, and destroy the account grouping configuration (+ discovery)",
19 (stack) =>
20 Effect.gen(function* () {
21 yield* stack.destroy();
22
23 // CREATE — one custom grouping dimension (plus the idempotent
24 // account-level Discovery enablement in the same stack).
25 const first = yield* stack.deploy(
26 Effect.gen(function* () {
27 const discovery = yield* Discovery("Discovery", {});
28 const grouping = yield* GroupingConfiguration("Grouping", {
29 groupingAttributeDefinitions: [
30 {
31 GroupingName: "AlchemyTestTeam",
32 GroupingSourceKeys: ["Tag.team"],
33 DefaultGroupingValue: "unassigned",
34 },
35 ],
36 });
37 return { discovery, grouping };
38 }),
39 );
40
41 expect(first.discovery.accountId).toMatch(/^\d{12}$/);
42 expect(first.grouping.groupingAttributeDefinitions.map((d) => d.GroupingName)).toEqual([
43 "AlchemyTestTeam",
44 ]);
45
46 // Out-of-band verification via distilled.
47 const observed = yield* observedDefinitions;
48 expect(observed.map((d) => d.GroupingName)).toEqual(["AlchemyTestTeam"]);
49 expect(observed[0].DefaultGroupingValue).toBe("unassigned");
50
51 // UPDATE IN PLACE — PutGroupingConfiguration replaces the whole list.
52 const second = yield* stack.deploy(
53 Effect.gen(function* () {
54 const discovery = yield* Discovery("Discovery", {});
55 const grouping = yield* GroupingConfiguration("Grouping", {
56 groupingAttributeDefinitions: [
57 {
58 GroupingName: "AlchemyTestTeam",
59 GroupingSourceKeys: ["Tag.team"],
60 },
61 {
62 GroupingName: "AlchemyTestCostCenter",
63 GroupingSourceKeys: ["Tag.cost-center"],
64 DefaultGroupingValue: "shared",
65 },
66 ],
67 });
68 return { discovery, grouping };
69 }),
70 );
71
72 expect(second.grouping.groupingAttributeDefinitions.map((d) => d.GroupingName)).toEqual([
73 "AlchemyTestTeam",
74 "AlchemyTestCostCenter",
75 ]);
76 const updated = yield* observedDefinitions;
77 expect(updated).toHaveLength(2);
78
79 // DESTROY — the account reverts to no grouping configuration.
80 // (Discovery deletion is a documented no-op.)
81 yield* stack.destroy();
82 const afterDestroy = yield* observedDefinitions;
83 expect(afterDestroy).toHaveLength(0);
84 }),
85 {
86 tags: ["provider:aws", "provider:aws:applicationsignals", "live"],
87 timeout: 120_000,
88 },
89 );