Skip to content

Commit 3e08cf6

Browse files
committed
test: schema-compatible assertions
1 parent a91a340 commit 3e08cf6

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

packages/core/src/submodules/protocols/ProtocolLib.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ export class ProtocolLib {
108108
const errorSchema = getErrorSchema?.(registry, errorName) ?? (registry.getSchema(errorIdentifier) as ErrorSchema);
109109
return { errorSchema, errorMetadata };
110110
} catch (e) {
111-
if (dataObject.Message) {
112-
dataObject.message = dataObject.Message;
113-
}
111+
dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";
114112
const baseExceptionSchema = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
115113
if (baseExceptionSchema) {
116114
const ErrorCtor = baseExceptionSchema.ctor;

private/aws-client-retry-test/src/ClientRetryTest.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ListFunctionsCommand, Lambda, LambdaClient, LambdaServiceException } from "@aws-sdk/client-lambda";
1+
import { Lambda, LambdaClient, LambdaServiceException, ListFunctionsCommand } from "@aws-sdk/client-lambda";
22
import { HttpHandler, HttpResponse } from "@smithy/protocol-http";
33
import { AwsCredentialIdentity, RequestHandlerOutput } from "@smithy/types";
44
import { ConfiguredRetryStrategy, StandardRetryStrategy } from "@smithy/util-retry";

private/aws-middleware-test/src/middleware-content-length.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
12
import { AccessAnalyzer } from "@aws-sdk/client-accessanalyzer";
23
import { S3 } from "@aws-sdk/client-s3";
34
import { XRay } from "@aws-sdk/client-xray";
45
import { describe, expect, test as it } from "vitest";
56

6-
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
7-
87
describe("middleware-content-length", () => {
98
describe(AccessAnalyzer.name, () => {
109
it("should not add content-length if no body", async () => {
@@ -40,14 +39,15 @@ describe("middleware-content-length", () => {
4039
headers: {
4140
"content-length": /106/,
4241
},
42+
body: /clientToken/, // must include idempotencyToken.
4343
});
4444

4545
await client.createAccessPreview({
4646
configurations: {},
4747
analyzerArn: "my-analyzer-arn",
4848
});
4949

50-
expect.assertions(1);
50+
expect.assertions(2);
5151
});
5252
});
5353

private/aws-middleware-test/src/middleware-serde.spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
12
import { EC2 } from "@aws-sdk/client-ec2";
23
import { S3 } from "@aws-sdk/client-s3";
34
import { SageMaker } from "@aws-sdk/client-sagemaker";
45
import { SageMakerRuntime } from "@aws-sdk/client-sagemaker-runtime";
56
import { describe, test as it } from "vitest";
67

7-
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
8-
98
describe("middleware-serde", () => {
109
describe(S3.name, () => {
1110
it("should serialize xml", async () => {
@@ -75,7 +74,15 @@ describe("middleware-serde", () => {
7574
"content-type": "application/x-www-form-urlencoded",
7675
host: "ec2.us-west-2.amazonaws.com",
7776
},
78-
body: /ClientCidrBlock=ClientCidrBlock&ServerCertificateArn=ServerCertificateArn(.*?)&Action=CreateClientVpnEndpoint&Version=2016-11-15/,
77+
body(body: any) {
78+
const params = Object.fromEntries(new URLSearchParams(body).entries());
79+
expect(params).toMatchObject({
80+
Action: "CreateClientVpnEndpoint",
81+
Version: "2016-11-15",
82+
ClientCidrBlock: "ClientCidrBlock",
83+
ServerCertificateArn: "ServerCertificateArn",
84+
});
85+
},
7986
protocol: "https:",
8087
path: "/",
8188
});

0 commit comments

Comments
 (0)