@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 83 lines 3.07 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { PreparedStatement } from "@alchemy.run/aws/Athena/PreparedStatement";
3 import { WorkGroup } from "@alchemy.run/aws/Athena/WorkGroup";
4 import { expect } from "@alchemy.run/test";
5 import * as Test from "@alchemy.run/test/Alchemy";
6 import * as athena from "@distilled.cloud/aws/athena";
7 import * as Provider from "alchemy/Provider";
8 import * as Effect from "effect/Effect";
9
10 const { test } = Test.make({ providers: AWS.providers() });
11
12 const wgName = "alchemy-test-athena-ps-wg";
13 const stmtName = "alchemy_test_prepared_stmt";
14
15 const getStatement = athena
16 .getPreparedStatement({ WorkGroup: wgName, StatementName: stmtName })
17 .pipe(
18 Effect.map((res) => res.PreparedStatement),
19 Effect.catchTag(["ResourceNotFoundException", "WorkGroupNotFound"], () =>
20 Effect.succeed(undefined),
21 ),
22 );
23
24 test.provider(
25 "lifecycle: create in a workgroup, update statement text, destroy",
26 (stack) =>
27 Effect.gen(function* () {
28 yield* stack.destroy();
29
30 // Create — a named statement saved in a dedicated workgroup.
31 const deployed = yield* stack.deploy(
32 Effect.gen(function* () {
33 const wg = yield* WorkGroup("PSWorkGroup", {
34 workGroupName: wgName,
35 });
36 return yield* PreparedStatement("Stmt", {
37 statementName: stmtName,
38 workGroup: wg.workGroupName,
39 queryStatement: "SELECT 1 AS one",
40 description: "alchemy prepared statement test",
41 });
42 }),
43 );
44 expect(deployed.statementName).toBe(stmtName);
45 expect(deployed.workGroup).toBe(wgName);
46 expect(deployed.queryStatement).toBe("SELECT 1 AS one");
47
48 // Out-of-band verification via distilled.
49 const created = yield* getStatement;
50 expect(created?.StatementName).toBe(stmtName);
51 expect(created?.QueryStatement).toBe("SELECT 1 AS one");
52 expect(created?.Description).toBe("alchemy prepared statement test");
53
54 // Canonical list() coverage.
55 const provider = yield* Provider.findProvider(PreparedStatement);
56 const all = yield* provider.list();
57 expect(all.some((ps) => ps.statementName === stmtName && ps.workGroup === wgName)).toBe(true);
58
59 // Update — statement text and description are updatable in place.
60 yield* stack.deploy(
61 Effect.gen(function* () {
62 const wg = yield* WorkGroup("PSWorkGroup", {
63 workGroupName: wgName,
64 });
65 return yield* PreparedStatement("Stmt", {
66 statementName: stmtName,
67 workGroup: wg.workGroupName,
68 queryStatement: "SELECT 2 AS two",
69 description: "updated",
70 });
71 }),
72 );
73 const updated = yield* getStatement;
74 expect(updated?.QueryStatement).toBe("SELECT 2 AS two");
75 expect(updated?.Description).toBe("updated");
76
77 // Destroy — statement (and its workgroup) are gone.
78 yield* stack.destroy();
79 const after = yield* getStatement;
80 expect(after).toBeUndefined();
81 }),
82 { tags: ["provider:aws", "provider:aws:athena", "live"], timeout: 180_000 },
83 );