1import * as AWS from "@/AWS";
2import * as Provider from "@/Provider";
3import * as Test from "./Test.ts";
4import * as ag from "@distilled.cloud/aws/api-gateway";
5import { expect } from "alchemy-test";
6import * as Effect from "effect/Effect";
7
8const { test } = Test.make({ providers: AWS.providers() });
9
10test.provider.skipIf(!!process.env.FAST)(
11 "patch API Gateway account settings",
12 (stack) =>
13 Effect.gen(function* () {
14 // Account settings are a singleton patch resource — the leading destroy
15 // clears any prior partial deployment before capturing the baseline.
16 yield* stack.destroy();
17
18 const before = yield* ag.getAccount({});
19
20 yield* stack.deploy(
21 Effect.gen(function* () {
22 yield* AWS.ApiGateway.Account("AgAccount", {});
23 return undefined;
24 }),
25 );
26
27 const account = yield* ag.getAccount({});
28 expect(account).toBeDefined();
29
30 yield* stack.destroy();
31
32 const after = yield* ag.getAccount({});
33 expect(after.cloudwatchRoleArn).toEqual(before.cloudwatchRoleArn);
34 }),
35 { tags: ["provider:aws", "provider:aws:apigateway", "live"] },
36);
37
38test.provider.skipIf(!!process.env.FAST)(
39 "list returns the account settings singleton",
40 (stack) =>
41 Effect.gen(function* () {
42 const provider = yield* Provider.findProvider(AWS.ApiGateway.Account);
43 const all = yield* provider.list();
44
45 // Account settings are an account/region singleton — always exactly one.
46 expect(all.length).toBe(1);
47 expect(all[0]).toHaveProperty("managesCloudwatchRoleArn");
48
49 yield* stack.destroy();
50 }),
51 { tags: ["provider:aws", "provider:aws:apigateway", "live"] },
52);