Skip to content

Commit 67f755f

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

File tree

1 file changed

+50
-13
lines changed

1 file changed

+50
-13
lines changed

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

Lines changed: 50 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,49 @@ 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+
// see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTSelectObjectAppendix.html
41+
yield new Uint8Array([
42+
/* message size */ ...[0, 0, 0, 97],
43+
/* header size */ ...[0, 0, 0, 81],
44+
/* prelude crc */ ...[221, 28, 224, 246],
45+
/* headers */
46+
/* :event-type */
47+
11,
48+
...[58, 101, 118, 101, 110, 116, 45, 116, 121, 112, 101],
49+
7,
50+
/* End */
51+
0,
52+
3,
53+
...[69, 110, 100],
54+
/* :content-type */
55+
13,
56+
...[58, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, 112, 101],
57+
7,
58+
/* application/octet-stream */
59+
0,
60+
24,
61+
...[
62+
97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 111, 99, 116, 101, 116, 45, 115, 116, 114,
63+
101, 97, 109,
64+
],
65+
/* :message-type */
66+
13,
67+
...[58, 109, 101, 115, 115, 97, 103, 101, 45, 116, 121, 112, 101],
68+
7,
69+
/* event */
70+
0,
71+
5,
72+
...[101, 118, 101, 110, 116],
73+
/* message crc */
74+
...[75, 107, 103, 102],
75+
]);
76+
},
77+
},
4778
})
4879
);
4980

@@ -69,5 +100,11 @@ describe("selectObjectContent", () => {
69100
expect(response.$metadata.httpStatusCode).toBe(200);
70101
expect(response).toHaveProperty("Payload");
71102
expect(response.Payload).toBeDefined();
103+
104+
const events = [];
105+
for await (const event of response.Payload!) {
106+
events.push(event);
107+
}
108+
expect(events).toEqual([{ End: {} }]);
72109
});
73110
});

0 commit comments

Comments
 (0)