Skip to content

Commit 320678f

Browse files
committed
test: fix lex runtime and mediastore payload tests
1 parent 281c666 commit 320678f

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

clients/client-lex-runtime-service/test/LexRuntimeService.spec.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
1-
import { HttpRequest } from "@smithy/protocol-http";
2-
import { SerializeMiddleware } from "@smithy/types";
3-
import { describe, expect, test as it } from "vitest";
1+
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
2+
import { Readable } from "node:stream";
3+
import { describe, test as it } from "vitest";
44

55
import { LexRuntimeService } from "../src/LexRuntimeService";
66

77
describe("@aws-sdk/client-lex-runtime-service", () => {
88
describe("PostContent", () => {
99
it("should contain correct x-amz-content-sha256 header", async () => {
10-
const validator: SerializeMiddleware<any, any> = (next) => (args) => {
11-
// middleware intercept the request and return it early
12-
const request = args.request as HttpRequest;
13-
expect(request.headers).to.have.property("x-amz-content-sha256", "UNSIGNED-PAYLOAD");
14-
return Promise.resolve({ output: {} as any, response: {} as any });
15-
};
1610
const client = new LexRuntimeService({
1711
region: "us-west-2",
1812
credentials: {
1913
accessKeyId: "CLIENT_TEST",
2014
secretAccessKey: "CLIENT_TEST",
2115
},
2216
});
23-
client.middlewareStack.add(validator, {
24-
step: "serialize",
25-
name: "endpointValidator",
26-
priority: "low",
17+
18+
requireRequestsFrom(client).toMatch({
19+
headers: {
20+
"x-amz-content-sha256": "UNSIGNED-PAYLOAD",
21+
},
2722
});
23+
2824
return await client.postContent({
2925
botAlias: "alias",
3026
botName: "bot",
3127
userId: "user",
3228
contentType: "text/plain; charset=utf-8",
33-
inputStream: "hello world!",
29+
inputStream: Readable.from(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])),
3430
});
3531
});
3632
});

clients/client-mediastore-data/test/MediaStoreData.spec.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
import { HttpRequest } from "@smithy/protocol-http";
2-
import { SerializeMiddleware } from "@smithy/types";
3-
import { describe, expect, test as it } from "vitest";
1+
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
2+
import { Readable } from "node:stream";
3+
import { describe, test as it } from "vitest";
44

55
import { MediaStoreData } from "../src/MediaStoreData";
66

77
describe("@aws-sdk/client-mediastore-data", () => {
88
describe("PutObject", () => {
99
it("should contain correct x-amz-content-sha256 header", async () => {
10-
const validator: SerializeMiddleware<any, any> = (next) => (args) => {
11-
// middleware intercept the request and return it early
12-
const request = args.request as HttpRequest;
13-
expect(request.headers).to.have.property("x-amz-content-sha256", "UNSIGNED-PAYLOAD");
14-
return Promise.resolve({ output: {} as any, response: {} as any });
15-
};
1610
const client = new MediaStoreData({
1711
region: "us-west-2",
1812
credentials: {
1913
accessKeyId: "CLIENT_TEST",
2014
secretAccessKey: "CLIENT_TEST",
2115
},
2216
});
23-
client.middlewareStack.add(validator, {
24-
step: "serialize",
25-
name: "endpointValidator",
26-
priority: "low",
17+
18+
requireRequestsFrom(client).toMatch({
19+
headers: {
20+
"x-amz-content-sha256": "UNSIGNED-PAYLOAD",
21+
},
2722
});
23+
2824
return await client.putObject({
2925
Path: "foo.avi",
30-
Body: "binary body",
26+
Body: Readable.from(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])),
3127
});
3228
});
3329
});

0 commit comments

Comments
 (0)