Skip to content

Commit 42185fb

Browse files
committed
test: fix select object content event stream test
1 parent 320678f commit 42185fb

File tree

1 file changed

+49
-13
lines changed

1 file changed

+49
-13
lines changed

clients/client-s3/test/integ/s3-selectObjectContent.integ.spec.ts

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
12
import { S3 } from "@aws-sdk/client-s3";
23
import { HttpResponse } from "@smithy/protocol-http";
3-
import { Readable } from "stream";
44
import { describe, expect, test as it } from "vitest";
55

6-
import { requireRequestsFrom } from "@aws-sdk/aws-util-test/src";
7-
86
describe("selectObjectContent", () => {
97
const credentials = {
108
accessKeyId: "INTEG",
@@ -34,16 +32,48 @@ describe("selectObjectContent", () => {
3432
.respondWith(
3533
new HttpResponse({
3634
statusCode: 200,
37-
body: Readable.from([
38-
`<?xml version="1.0" encoding="UTF-8"?>`,
39-
`<Payload>`,
40-
`<Records><Payload>blob</Payload></Records>`,
41-
`<Stats><Details><BytesProcessed>100</BytesProcessed><BytesReturned>50</BytesReturned><BytesScanned>100</BytesScanned></Details></Stats>`,
42-
`<Progress><Details><BytesProcessed>100</BytesProcessed><BytesReturned>50</BytesReturned><BytesScanned>100</BytesScanned></Details></Progress>`,
43-
`<Cont></Cont>`,
44-
`<End></End>`,
45-
`</Payload>`,
46-
]),
35+
headers: {
36+
"x-amz-checksum-crc32": "3117266289",
37+
},
38+
body: {
39+
*[Symbol.asyncIterator]() {
40+
yield new Uint8Array([
41+
/* message size */ ...[0, 0, 0, 97],
42+
/* header size */ ...[0, 0, 0, 81],
43+
/* prelude crc */ ...[221, 28, 224, 246],
44+
/* headers */
45+
/* :event-type */
46+
11,
47+
...[58, 101, 118, 101, 110, 116, 45, 116, 121, 112, 101],
48+
7,
49+
/* End */
50+
0,
51+
3,
52+
...[69, 110, 100],
53+
/* :content-type */
54+
13,
55+
...[58, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101],
56+
7,
57+
/* application/octet-stream */
58+
0,
59+
24,
60+
...[
61+
97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 111, 99, 116, 101, 116, 45, 115, 116, 114,
62+
101, 97, 109,
63+
],
64+
/* :message-type */
65+
13,
66+
...[58, 109, 101, 115, 115, 97, 103, 101, 45, 116, 121, 112, 101],
67+
7,
68+
/* event */
69+
0,
70+
5,
71+
...[101, 118, 101, 110, 116],
72+
/* message crc */
73+
...[75, 107, 103, 102],
74+
]);
75+
},
76+
},
4777
})
4878
);
4979

@@ -69,5 +99,11 @@ describe("selectObjectContent", () => {
6999
expect(response.$metadata.httpStatusCode).toBe(200);
70100
expect(response).toHaveProperty("Payload");
71101
expect(response.Payload).toBeDefined();
102+
103+
const events = [];
104+
for await (const event of response.Payload!) {
105+
events.push(event);
106+
}
107+
expect(events).toEqual([{ End: {} }]);
72108
});
73109
});

0 commit comments

Comments
 (0)