@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.46 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { RetentionConfiguration } from "@alchemy.run/aws/Config";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as config from "@distilled.cloud/aws/config-service";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 // Ungated typed-error probe: prove the distilled error union carries the
11 // not-found tag this provider's read/delete paths depend on.
12 test.provider(
13 "describeRetentionConfigurations on a nonexistent name fails with NoSuchRetentionConfigurationException",
14 () =>
15 Effect.gen(function* () {
16 const error = yield* Effect.flip(
17 config.describeRetentionConfigurations({
18 RetentionConfigurationNames: ["alchemy-nonexistent-retention-probe"],
19 }),
20 );
21 expect(error._tag).toBe("NoSuchRetentionConfigurationException");
22 }),
23 { tags: ["provider:aws", "provider:aws:config", "live"] },
24 );
25
26 const observeRetention = config.describeRetentionConfigurations({}).pipe(
27 Effect.map((r) => (r.RetentionConfigurations ?? []).at(0)),
28 Effect.catchTag("NoSuchRetentionConfigurationException", () => Effect.succeed(undefined)),
29 );
30
31 // The retention configuration is an account-region singleton AWS always
32 // names `default` — capture any preexisting configuration up front and
33 // restore it after the lifecycle (success, failure, or interruption) so the
34 // test never permanently mutates a shared account setting.
35 const restorePrior = (prior: config.RetentionConfiguration | undefined) =>
36 (prior === undefined
37 ? Effect.void
38 : config
39 .putRetentionConfiguration({
40 RetentionPeriodInDays: prior.RetentionPeriodInDays,
41 })
42 .pipe(Effect.asVoid)
43 ).pipe(Effect.orDie);
44
45 test.provider(
46 "create, update, delete retention configuration (Duration retentionPeriod)",
47 (stack) =>
48 Effect.gen(function* () {
49 yield* stack.destroy();
50 const prior = yield* observeRetention;
51
52 yield* Effect.gen(function* () {
53 // Create — "90 days" exercises the Duration.Input -> wire-days path.
54 const created = yield* stack.deploy(
55 Effect.gen(function* () {
56 return yield* RetentionConfiguration("Retention", {
57 retentionPeriod: "90 days",
58 });
59 }),
60 );
61 expect(created.retentionConfigurationName).toBe("default");
62 expect(created.retentionPeriodInDays).toBe(90);
63
64 // Out-of-band verification via distilled.
65 const observed = yield* observeRetention;
66 expect(observed?.Name).toBe("default");
67 expect(observed?.RetentionPeriodInDays).toBe(90);
68
69 // Update in place (singleton upsert).
70 const updated = yield* stack.deploy(
71 Effect.gen(function* () {
72 return yield* RetentionConfiguration("Retention", {
73 retentionPeriod: "180 days",
74 });
75 }),
76 );
77 expect(updated.retentionConfigurationName).toBe("default");
78 expect(updated.retentionPeriodInDays).toBe(180);
79 const afterUpdate = yield* observeRetention;
80 expect(afterUpdate?.RetentionPeriodInDays).toBe(180);
81
82 // Destroy and verify the singleton is gone.
83 yield* stack.destroy();
84 const afterDestroy = yield* observeRetention;
85 expect(afterDestroy).toBeUndefined();
86 }).pipe(Effect.ensuring(restorePrior(prior)));
87 }),
88 { tags: ["provider:aws", "provider:aws:config", "live"], timeout: 120_000 },
89 );