@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 97 lines 3.74 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { SyncConfiguration } from "@alchemy.run/aws/CodeConnections/SyncConfiguration";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as codeconnections from "@distilled.cloud/aws/codeconnections";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 // A sync configuration requires a repository link, which itself requires a
11 // connection in the AVAILABLE state — and completing a connection's OAuth
12 // handshake is a manual console step with no API. The ungated probe proves
13 // the read wiring end-to-end (typed NotFound from the real service); the
14 // full lifecycle is gated on a manually-provisioned repository link + role.
15 const REPOSITORY_LINK_ID = process.env.AWS_TEST_CODECONNECTIONS_REPO_LINK_ID;
16 const GIT_SYNC_ROLE_ARN = process.env.AWS_TEST_CODECONNECTIONS_SYNC_ROLE_ARN;
17
18 test.provider(
19 "probe: reading a nonexistent sync configuration surfaces the typed NotFound",
20 () =>
21 Effect.gen(function* () {
22 const tag = yield* codeconnections
23 .getSyncConfiguration({
24 SyncType: "CFN_STACK_SYNC",
25 ResourceName: "alchemy-test-nonexistent-stack",
26 })
27 .pipe(
28 Effect.map(() => "Found" as const),
29 Effect.catchTag("ResourceNotFoundException", (e) => Effect.succeed(e._tag)),
30 );
31 expect(tag).toBe("ResourceNotFoundException");
32 }),
33 {
34 tags: ["provider:aws", "provider:aws:codeconnections", "live"],
35 timeout: 60_000,
36 },
37 );
38
39 test.provider.skipIf(!REPOSITORY_LINK_ID || !GIT_SYNC_ROLE_ARN)(
40 "lifecycle: create stack sync, update trigger, destroy (gated: AWS_TEST_CODECONNECTIONS_REPO_LINK_ID)",
41 (stack) =>
42 Effect.gen(function* () {
43 yield* stack.destroy();
44
45 const deployed = yield* stack.deploy(
46 Effect.gen(function* () {
47 return yield* SyncConfiguration("StackSync", {
48 branch: "main",
49 configFile: "deployments/alchemy-test-stack.yaml",
50 repositoryLinkId: REPOSITORY_LINK_ID!,
51 resourceName: "alchemy-test-sync-stack",
52 roleArn: GIT_SYNC_ROLE_ARN!,
53 });
54 }),
55 );
56 expect(deployed.syncType).toBe("CFN_STACK_SYNC");
57 expect(deployed.resourceName).toBe("alchemy-test-sync-stack");
58 expect(deployed.branch).toBe("main");
59
60 // Update — trigger mode is mutable via UpdateSyncConfiguration.
61 const updated = yield* stack.deploy(
62 Effect.gen(function* () {
63 return yield* SyncConfiguration("StackSync", {
64 branch: "main",
65 configFile: "deployments/alchemy-test-stack.yaml",
66 repositoryLinkId: REPOSITORY_LINK_ID!,
67 resourceName: "alchemy-test-sync-stack",
68 roleArn: GIT_SYNC_ROLE_ARN!,
69 triggerResourceUpdateOn: "FILE_CHANGE",
70 });
71 }),
72 );
73 expect(updated.resourceName).toBe(deployed.resourceName);
74 const observed = yield* codeconnections.getSyncConfiguration({
75 SyncType: "CFN_STACK_SYNC",
76 ResourceName: "alchemy-test-sync-stack",
77 });
78 expect(observed.SyncConfiguration.TriggerResourceUpdateOn).toBe("FILE_CHANGE");
79
80 // Destroy — configuration is deleted; verify out-of-band.
81 yield* stack.destroy();
82 const after = yield* codeconnections
83 .getSyncConfiguration({
84 SyncType: "CFN_STACK_SYNC",
85 ResourceName: "alchemy-test-sync-stack",
86 })
87 .pipe(
88 Effect.map((res) => res.SyncConfiguration),
89 Effect.catchTag("ResourceNotFoundException", () => Effect.succeed(undefined)),
90 );
91 expect(after).toBeUndefined();
92 }),
93 {
94 tags: ["provider:aws", "provider:aws:codeconnections", "live"],
95 timeout: 120_000,
96 },
97 );