@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, 06:00 UTC

main
ts 95 lines 4.03 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Datastore } from "@alchemy.run/aws/MedicalImaging";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as medicalimaging from "@distilled.cloud/aws/medical-imaging";
6 import * as Effect from "effect/Effect";
7 import * as Schedule from "effect/Schedule";
8
9 const { test } = Test.make({ providers: AWS.providers() });
10
11 // Ungated typed-error probe: prove the distilled error union carries the
12 // not-found tag this provider's read/delete paths depend on. Runs in every
13 // CI pass at near-zero cost, unlike the gated lifecycle below.
14 test.provider(
15 "getDatastore on a nonexistent id fails with ResourceNotFoundException",
16 () =>
17 Effect.gen(function* () {
18 const error = yield* Effect.flip(
19 // well-formed (32 hex chars) but nonexistent datastore id
20 medicalimaging.getDatastore({ datastoreId: "00000000000000000000000000000000" }),
21 );
22 expect(error._tag).toBe("ResourceNotFoundException");
23 }),
24 { tags: ["provider:aws", "provider:aws:medicalimaging", "live"] },
25 );
26
27 // Deletion is async (DELETING → gone); poll bounded until the store no
28 // longer resolves (or reports DELETED).
29 const assertDatastoreGone = (datastoreId: string) =>
30 Effect.gen(function* () {
31 const status = yield* medicalimaging.getDatastore({ datastoreId }).pipe(
32 Effect.map((r) => r.datastoreProperties.datastoreStatus as string | "gone"),
33 Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("gone" as const)),
34 );
35 if (status !== "gone" && status !== "DELETED") {
36 return yield* Effect.fail(
37 new Error(`datastore '${datastoreId}' still exists (status: ${status})`),
38 );
39 }
40 }).pipe(
41 Effect.retry({ schedule: Schedule.max([Schedule.fixed("10 seconds"), Schedule.recurs(30)]) }),
42 );
43
44 // A HealthImaging data store provisions asynchronously (CREATING → ACTIVE,
45 // ~2 minutes observed) and deletes asynchronously too. A data store has no
46 // fixed charge, so the lifecycle runs by default (skipped under --fast) and
47 // always destroys what it created.
48 test.provider.skipIf(!!process.env.FAST)(
49 "create data store, update tags, destroy",
50 (stack) =>
51 Effect.gen(function* () {
52 yield* stack.destroy();
53
54 const { datastore } = yield* stack.deploy(
55 Effect.gen(function* () {
56 const datastore = yield* Datastore("Store", { tags: { fixture: "medical-imaging" } });
57 return { datastore };
58 }),
59 );
60
61 expect(datastore.datastoreId).toBeDefined();
62 expect(datastore.datastoreArn).toContain(":datastore/");
63 expect(datastore.datastoreStatus).toBe("ACTIVE");
64 expect(datastore.tags.fixture).toBe("medical-imaging");
65
66 // Out-of-band verification via distilled.
67 const observed = yield* medicalimaging.getDatastore({ datastoreId: datastore.datastoreId });
68 expect(observed.datastoreProperties.datastoreStatus).toBe("ACTIVE");
69 expect(observed.datastoreProperties.datastoreName).toBe(datastore.datastoreName);
70
71 // Update path: tags are the only mutable aspect (HealthImaging has no
72 // UpdateDatastore); the same physical store must be reused.
73 const { datastore: updated } = yield* stack.deploy(
74 Effect.gen(function* () {
75 const datastore = yield* Datastore("Store", {
76 tags: { fixture: "medical-imaging", extra: "added" },
77 });
78 return { datastore };
79 }),
80 );
81 expect(updated.datastoreId).toBe(datastore.datastoreId);
82 expect(updated.tags.extra).toBe("added");
83
84 const observedTags = yield* medicalimaging.listTagsForResource({
85 resourceArn: datastore.datastoreArn,
86 });
87 expect(observedTags.tags?.extra).toBe("added");
88
89 // Destroy and verify deletion completes out-of-band (DELETING → gone).
90 yield* stack.destroy();
91 yield* assertDatastoreGone(datastore.datastoreId);
92 }),
93 // async create (a few minutes) + tag update + async delete, one test.
94 { tags: ["provider:aws", "provider:aws:medicalimaging", "live"], timeout: 1_200_000 },
95 );