| 1 | import * as AWS from "@/AWS"; |
| 2 | import { DBClusterParameterGroup } from "@/AWS/RDS/DBClusterParameterGroup.ts"; |
| 3 | import * as Provider from "@/Provider"; |
| 4 | import * as Test from "@/Test/Alchemy"; |
| 5 | import { expect } from "alchemy-test"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: AWS.providers() }); |
| 9 | |
| 10 | // Canonical `list()` test (AWS account/region-scoped collection). Cluster |
| 11 | // parameter groups create and delete fast (well within the 240s budget), so we |
| 12 | // deploy a real group, resolve the provider via the typed |
| 13 | // `Provider.findProvider(DBClusterParameterGroup)` so `list()`'s element type is |
| 14 | // the exact `DBClusterParameterGroup["Attributes"]` shape, call it, and assert |
| 15 | // the deployed group appears in the exhaustively-paginated result. |
| 16 | test.provider( |
| 17 | "list enumerates the deployed DB cluster parameter group", |
| 18 | (stack) => |
| 19 | Effect.gen(function* () { |
| 20 | yield* stack.destroy(); |
| 21 | |
| 22 | const group = yield* stack.deploy( |
| 23 | Effect.gen(function* () { |
| 24 | return yield* DBClusterParameterGroup("ListDBClusterParameterGroup", { |
| 25 | dbClusterParameterGroupName: "alchemy-test-dbcpg-list", |
| 26 | family: "aurora-postgresql16", |
| 27 | description: "Alchemy list() test cluster parameter group", |
| 28 | }); |
| 29 | }), |
| 30 | ); |
| 31 | |
| 32 | const provider = yield* Provider.findProvider(DBClusterParameterGroup); |
| 33 | const all = yield* provider.list(); |
| 34 | |
| 35 | expect(Array.isArray(all)).toBe(true); |
| 36 | expect( |
| 37 | all.some( |
| 38 | (g) => |
| 39 | g.dbClusterParameterGroupName === group.dbClusterParameterGroupName, |
| 40 | ), |
| 41 | ).toBe(true); |
| 42 | |
| 43 | for (const g of all) { |
| 44 | expect(typeof g.dbClusterParameterGroupName).toBe("string"); |
| 45 | expect(typeof g.family).toBe("string"); |
| 46 | } |
| 47 | |
| 48 | yield* stack.destroy(); |
| 49 | }), |
| 50 | { tags: ["provider:aws", "provider:aws:rds", "live"] }, |
| 51 | ); |