t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/AWS/Glue/Connection.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

83 lines
2.9 KiB
TypeScript

import * as AWS from "@/AWS";
import { Connection } from "@/AWS/Glue";
import * as Test from "@/Test/Alchemy";
import * as glue from "@distilled.cloud/aws/glue";
import { expect } from "alchemy-test";
import * as Effect from "effect/Effect";
import * as Redacted from "effect/Redacted";
const { test } = Test.make({ providers: AWS.providers() });
const getConnection = (name: string) =>
glue.getConnection({ Name: name, HidePassword: true }).pipe(
Effect.map((r) => r.Connection),
Effect.catchTag("EntityNotFoundException", () => Effect.succeed(undefined)),
);
test.provider(
"create, update, delete Glue JDBC connection",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const created = yield* stack.deploy(
Effect.gen(function* () {
return yield* Connection("Warehouse", {
connectionType: "JDBC",
description: "warehouse jdbc",
connectionProperties: {
JDBC_CONNECTION_URL:
"jdbc:postgresql://db.example.com:5432/warehouse",
USERNAME: "glue",
PASSWORD: Redacted.make("secret"),
},
tags: { Environment: "test" },
});
}),
);
expect(created.connectionName).toBeDefined();
expect(created.connectionType).toEqual("JDBC");
expect(created.connectionArn).toContain(
`:connection/${created.connectionName}`,
);
const observed = yield* getConnection(created.connectionName);
expect(observed?.Name).toEqual(created.connectionName);
expect(observed?.ConnectionType).toEqual("JDBC");
expect(observed?.ConnectionProperties?.JDBC_CONNECTION_URL).toEqual(
"jdbc:postgresql://db.example.com:5432/warehouse",
);
const tags = yield* glue.getTags({ ResourceArn: created.connectionArn });
expect(tags.Tags?.["alchemy::id"]).toBeDefined();
expect(tags.Tags?.Environment).toEqual("test");
// update the JDBC URL
yield* stack.deploy(
Effect.gen(function* () {
return yield* Connection("Warehouse", {
connectionType: "JDBC",
description: "warehouse jdbc v2",
connectionProperties: {
JDBC_CONNECTION_URL:
"jdbc:postgresql://db2.example.com:5432/warehouse",
USERNAME: "glue",
PASSWORD: Redacted.make("secret"),
},
tags: { Environment: "test" },
});
}),
);
const reobserved = yield* getConnection(created.connectionName);
expect(reobserved?.ConnectionProperties?.JDBC_CONNECTION_URL).toEqual(
"jdbc:postgresql://db2.example.com:5432/warehouse",
);
yield* stack.destroy();
const gone = yield* getConnection(created.connectionName);
expect(gone).toBeUndefined();
}),
{ tags: ["provider:aws", "provider:aws:glue", "live"] },
);