@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 79 lines 2.84 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Connection } from "@alchemy.run/aws/Glue";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as glue from "@distilled.cloud/aws/glue";
6 import * as Effect from "effect/Effect";
7 import * as Redacted from "effect/Redacted";
8
9 const { test } = Test.make({ providers: AWS.providers() });
10
11 const getConnection = (name: string) =>
12 glue.getConnection({ Name: name, HidePassword: true }).pipe(
13 Effect.map((r) => r.Connection),
14 Effect.catchTag("EntityNotFoundException", () => Effect.succeed(undefined)),
15 );
16
17 test.provider(
18 "create, update, delete Glue JDBC connection",
19 (stack) =>
20 Effect.gen(function* () {
21 yield* stack.destroy();
22
23 const created = yield* stack.deploy(
24 Effect.gen(function* () {
25 return yield* Connection("Warehouse", {
26 connectionType: "JDBC",
27 description: "warehouse jdbc",
28 connectionProperties: {
29 JDBC_CONNECTION_URL: "jdbc:postgresql://db.example.com:5432/warehouse",
30 USERNAME: "glue",
31 PASSWORD: Redacted.make("secret"),
32 },
33 tags: { Environment: "test" },
34 });
35 }),
36 );
37
38 expect(created.connectionName).toBeDefined();
39 expect(created.connectionType).toEqual("JDBC");
40 expect(created.connectionArn).toContain(`:connection/${created.connectionName}`);
41
42 const observed = yield* getConnection(created.connectionName);
43 expect(observed?.Name).toEqual(created.connectionName);
44 expect(observed?.ConnectionType).toEqual("JDBC");
45 expect(observed?.ConnectionProperties?.JDBC_CONNECTION_URL).toEqual(
46 "jdbc:postgresql://db.example.com:5432/warehouse",
47 );
48
49 const tags = yield* glue.getTags({ ResourceArn: created.connectionArn });
50 expect(tags.Tags?.["alchemy::id"]).toBeDefined();
51 expect(tags.Tags?.Environment).toEqual("test");
52
53 // update the JDBC URL
54 yield* stack.deploy(
55 Effect.gen(function* () {
56 return yield* Connection("Warehouse", {
57 connectionType: "JDBC",
58 description: "warehouse jdbc v2",
59 connectionProperties: {
60 JDBC_CONNECTION_URL: "jdbc:postgresql://db2.example.com:5432/warehouse",
61 USERNAME: "glue",
62 PASSWORD: Redacted.make("secret"),
63 },
64 tags: { Environment: "test" },
65 });
66 }),
67 );
68
69 const reobserved = yield* getConnection(created.connectionName);
70 expect(reobserved?.ConnectionProperties?.JDBC_CONNECTION_URL).toEqual(
71 "jdbc:postgresql://db2.example.com:5432/warehouse",
72 );
73
74 yield* stack.destroy();
75 const gone = yield* getConnection(created.connectionName);
76 expect(gone).toBeUndefined();
77 }),
78 { tags: ["provider:aws", "provider:aws:glue", "live"] },
79 );