The best way to control Claude Code, Codex and more from any computer or phone

main
ts 84 lines 2.83 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 sagemaker from "@distilled.cloud/aws/sagemaker-runtime";
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 // Ungated typed-error probe: invoking a nonexistent endpoint must surface as a
11 // typed `ValidationError` from distilled's `InvokeEndpointError` union — this
12 // proves both the SDK's typed error mapping and that the binding's callable is
13 // wired against the real data-plane API, at near-zero cost (no endpoint is
14 // provisioned — a real endpoint costs $$ per hour). The full live invocation
15 // (with a real deployed endpoint) is gated behind AWS_TEST_SAGEMAKER_ENDPOINT=1
16 // in test/AWS/SageMaker/Endpoint.test.ts.
17 test.provider(
18 "invoking a nonexistent endpoint returns a typed ValidationError",
19 (_stack) =>
20 Effect.gen(function* () {
21 const result = yield* Effect.result(
22 sagemaker.invokeEndpoint({
23 EndpointName: "alchemy-nonexistent-endpoint-probe",
24 ContentType: "application/json",
25 Body: JSON.stringify({ instances: [[0]] }),
26 }),
27 );
28
29 expect(Result.isFailure(result)).toBe(true);
30 if (Result.isFailure(result)) {
31 expect(result.failure._tag).toBe("ValidationError");
32 }
33 }),
34 {
35 tags: ["provider:aws", "provider:aws:sagemakerruntime", "live"],
36 timeout: 60_000,
37 },
38 );
39
40 test.provider(
41 "async-invoking a nonexistent endpoint returns a typed ValidationError",
42 (_stack) =>
43 Effect.gen(function* () {
44 const result = yield* Effect.result(
45 sagemaker.invokeEndpointAsync({
46 EndpointName: "alchemy-nonexistent-endpoint-probe",
47 ContentType: "application/json",
48 InputLocation: "s3://alchemy-nonexistent-bucket-probe/input/request.json",
49 }),
50 );
51
52 expect(Result.isFailure(result)).toBe(true);
53 if (Result.isFailure(result)) {
54 expect(result.failure._tag).toBe("ValidationError");
55 }
56 }),
57 {
58 tags: ["provider:aws", "provider:aws:sagemakerruntime", "live"],
59 timeout: 60_000,
60 },
61 );
62
63 test.provider(
64 "stream-invoking a nonexistent endpoint returns a typed ValidationError",
65 (_stack) =>
66 Effect.gen(function* () {
67 const result = yield* Effect.result(
68 sagemaker.invokeEndpointWithResponseStream({
69 EndpointName: "alchemy-nonexistent-endpoint-probe",
70 ContentType: "application/json",
71 Body: JSON.stringify({ inputs: "hello" }),
72 }),
73 );
74
75 expect(Result.isFailure(result)).toBe(true);
76 if (Result.isFailure(result)) {
77 expect(result.failure._tag).toBe("ValidationError");
78 }
79 }),
80 {
81 tags: ["provider:aws", "provider:aws:sagemakerruntime", "live"],
82 timeout: 60_000,
83 },
84 );