| 1 | import * as AWS from "@/AWS"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import * as finspace from "@distilled.cloud/aws/finspace"; |
| 4 | import { expect } from "alchemy-test"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | |
| 7 | const { test } = Test.make({ providers: AWS.providers() }); |
| 8 | |
| 9 | // FinSpace Managed kdb is closed to non-onboarded accounts, so the runtime |
| 10 | // bindings (all scoped to a live KxEnvironment) cannot be exercised through a |
| 11 | // deployed Lambda fixture here — deploying the fixture requires a real kdb |
| 12 | // environment (tens of minutes, gated onboarding). These ungated typed-error |
| 13 | // probes instead prove, against the live API, that every operation the |
| 14 | // bindings wrap carries the typed not-found tag in its distilled error union |
| 15 | // — the same tags a bound function observes at runtime. |
| 16 | // |
| 17 | // environmentId must match ^[a-zA-Z0-9]{1,26}$ — malformed ids fail earlier |
| 18 | // with ValidationException. |
| 19 | const missingEnvironmentId = "zzzzzzzzzzzzzzzzzzzzzzzzzz"; |
| 20 | |
| 21 | test.provider( |
| 22 | "getKxConnectionString on a nonexistent environment fails with ResourceNotFoundException", |
| 23 | () => |
| 24 | Effect.gen(function* () { |
| 25 | const error = yield* Effect.flip( |
| 26 | finspace.getKxConnectionString({ |
| 27 | environmentId: missingEnvironmentId, |
| 28 | clusterName: "nocluster", |
| 29 | userArn: `arn:aws:finspace:us-east-1:123456789012:kxEnvironment/${missingEnvironmentId}/kxUser/nouser`, |
| 30 | }), |
| 31 | ); |
| 32 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 33 | }), |
| 34 | { tags: ["provider:aws", "provider:aws:finspace", "live"] }, |
| 35 | ); |
| 36 | |
| 37 | test.provider( |
| 38 | "createKxChangeset on a nonexistent environment fails with ResourceNotFoundException", |
| 39 | () => |
| 40 | Effect.gen(function* () { |
| 41 | const error = yield* Effect.flip( |
| 42 | finspace.createKxChangeset({ |
| 43 | environmentId: missingEnvironmentId, |
| 44 | databaseName: "nodb", |
| 45 | changeRequests: [ |
| 46 | { |
| 47 | changeType: "PUT", |
| 48 | s3Path: "s3://nonexistent-bucket/nonexistent/", |
| 49 | dbPath: "/2024.01.02/", |
| 50 | }, |
| 51 | ], |
| 52 | clientToken: "alchemy-finspace-probe-changeset", |
| 53 | }), |
| 54 | ); |
| 55 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 56 | }), |
| 57 | { tags: ["provider:aws", "provider:aws:finspace", "live"] }, |
| 58 | ); |
| 59 | |
| 60 | test.provider( |
| 61 | "listKxChangesets on a nonexistent environment fails with ResourceNotFoundException", |
| 62 | () => |
| 63 | Effect.gen(function* () { |
| 64 | const error = yield* Effect.flip( |
| 65 | finspace.listKxChangesets({ |
| 66 | environmentId: missingEnvironmentId, |
| 67 | databaseName: "nodb", |
| 68 | }), |
| 69 | ); |
| 70 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 71 | }), |
| 72 | { tags: ["provider:aws", "provider:aws:finspace", "live"] }, |
| 73 | ); |
| 74 | |
| 75 | test.provider( |
| 76 | "listKxClusterNodes on a nonexistent environment fails with ResourceNotFoundException", |
| 77 | () => |
| 78 | Effect.gen(function* () { |
| 79 | const error = yield* Effect.flip( |
| 80 | finspace.listKxClusterNodes({ |
| 81 | environmentId: missingEnvironmentId, |
| 82 | clusterName: "nocluster", |
| 83 | }), |
| 84 | ); |
| 85 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 86 | }), |
| 87 | { tags: ["provider:aws", "provider:aws:finspace", "live"] }, |
| 88 | ); |
| 89 | |
| 90 | test.provider( |
| 91 | "getKxDataview on a nonexistent environment fails with ResourceNotFoundException", |
| 92 | () => |
| 93 | Effect.gen(function* () { |
| 94 | const error = yield* Effect.flip( |
| 95 | finspace.getKxDataview({ |
| 96 | environmentId: missingEnvironmentId, |
| 97 | databaseName: "nodb", |
| 98 | dataviewName: "noview", |
| 99 | }), |
| 100 | ); |
| 101 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 102 | }), |
| 103 | { tags: ["provider:aws", "provider:aws:finspace", "live"] }, |
| 104 | ); |
| 105 | |
| 106 | test.provider( |
| 107 | "getKxUser on a nonexistent environment fails with ResourceNotFoundException", |
| 108 | () => |
| 109 | Effect.gen(function* () { |
| 110 | const error = yield* Effect.flip( |
| 111 | finspace.getKxUser({ |
| 112 | environmentId: missingEnvironmentId, |
| 113 | userName: "nouser", |
| 114 | }), |
| 115 | ); |
| 116 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 117 | }), |
| 118 | { tags: ["provider:aws", "provider:aws:finspace", "live"] }, |
| 119 | ); |