| 1 | import * as AWS from "@/AWS"; |
| 2 | import * as Provider from "@/Provider"; |
| 3 | import * as Test from "./Test.ts"; |
| 4 | import * as ag from "@distilled.cloud/aws/api-gateway"; |
| 5 | import { expect } from "alchemy-test"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: AWS.providers() }); |
| 9 | |
| 10 | test.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 | |
| 38 | test.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 | ); |