@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 91 lines 3.15 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as appsync from "@distilled.cloud/aws/appsync";
5 import * as Effect from "effect/Effect";
6 import * as Result from "effect/Result";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 const SCHEMA = `
11 type Query {
12 hello: String
13 }
14 schema { query: Query }
15 `;
16
17 // AppSync custom domains require an ACM certificate in us-east-1
18 // (CloudFront-backed). The full lifecycle is gated on a standing cert;
19 // the ungated probe below pins the typed rejection forever.
20 const domainName = process.env.AWS_TEST_APPSYNC_DOMAIN_NAME;
21 const certificateArn = process.env.AWS_TEST_APPSYNC_DOMAIN_CERT_ARN;
22
23 test.provider(
24 "createDomainName rejects a certificate that does not exist (typed probe)",
25 () =>
26 Effect.gen(function* () {
27 const result = yield* Effect.result(
28 appsync.createDomainName({
29 domainName: "alchemy-appsync-probe.example.com",
30 certificateArn:
31 "arn:aws:acm:us-east-1:000000000000:certificate/00000000-0000-0000-0000-000000000000",
32 }),
33 );
34 expect(Result.isFailure(result)).toBe(true);
35 if (Result.isFailure(result)) {
36 // Cross-account/nonexistent cert surfaces as the typed
37 // BadRequestException (or AccessDenied depending on validation
38 // order) — never an untyped catch-all.
39 expect(["BadRequestException", "AccessDeniedException"]).toContain(result.failure._tag);
40 }
41 }),
42 { tags: ["provider:aws", "provider:aws:appsync", "live"], timeout: 60_000 },
43 );
44
45 test.provider.skipIf(!domainName || !certificateArn)(
46 "custom domain + api association lifecycle (gated)",
47 (stack) =>
48 Effect.gen(function* () {
49 yield* stack.destroy();
50
51 const out = yield* stack.deploy(
52 Effect.gen(function* () {
53 const api = yield* AWS.AppSync.GraphqlApi("DomainApi", {
54 schema: SCHEMA,
55 });
56 const domain = yield* AWS.AppSync.DomainName("Domain", {
57 domainName: domainName!,
58 certificateArn: certificateArn!,
59 description: "alchemy test domain",
60 });
61 yield* AWS.AppSync.ApiAssociation("Assoc", { domain, api });
62 return {
63 apiId: api.apiId,
64 domainName: domain.domainName,
65 appsyncDomainName: domain.appsyncDomainName,
66 };
67 }),
68 );
69
70 expect(out.appsyncDomainName).toContain("cloudfront");
71
72 const remote = yield* appsync.getDomainName({
73 domainName: out.domainName,
74 });
75 expect(remote.domainNameConfig?.certificateArn).toBe(certificateArn);
76
77 const association = yield* appsync.getApiAssociation({
78 domainName: out.domainName,
79 });
80 expect(association.apiAssociation?.apiId).toBe(out.apiId);
81
82 yield* stack.destroy();
83
84 const gone = yield* appsync.getDomainName({ domainName: out.domainName }).pipe(
85 Effect.map(() => false),
86 Effect.catchTag("NotFoundException", () => Effect.succeed(true)),
87 );
88 expect(gone).toBe(true);
89 }),
90 { tags: ["provider:aws", "provider:aws:appsync", "live"], timeout: 240_000 },
91 );