Skip to content

Commit cd08e4e

Browse files
committed
test(client-s3): add integration test for selectObjectContent
1 parent f32c1f1 commit cd08e4e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { S3 } from "@aws-sdk/client-s3";
2+
import { describe, expect, test as it } from "vitest";
3+
4+
import { requireRequestsFrom } from "../../../../private/aws-util-test/src";
5+
6+
describe("selectObjectContent", () => {
7+
const credentials = {
8+
accessKeyId: "INTEG",
9+
secretAccessKey: "INTEG",
10+
};
11+
12+
it("should make correct request", async () => {
13+
const client = new S3({ region: "us-west-2", credentials });
14+
15+
requireRequestsFrom(client).toMatch({
16+
hostname: /aws-sdk-js-integ-test-bucket\.s3\.us-west-2\.amazonaws\.com/,
17+
method: "POST",
18+
path: "/test-key",
19+
headers: {
20+
authorization: /AWS4-HMAC-SHA256 Credential/,
21+
"content-type": "application/xml",
22+
"x-amz-content-sha256": /./,
23+
},
24+
body(xmlBody) {
25+
expect(xmlBody).toContain(
26+
"<Expression>SELECT user_name FROM S3Object WHERE cast(age as int) &gt; 20</Expression>"
27+
);
28+
expect(xmlBody).toContain("<ExpressionType>SQL</ExpressionType>");
29+
},
30+
});
31+
32+
await client.selectObjectContent({
33+
Bucket: "aws-sdk-js-integ-test-bucket",
34+
Key: "test-key",
35+
ExpressionType: "SQL",
36+
Expression: "SELECT user_name FROM S3Object WHERE cast(age as int) > 20",
37+
InputSerialization: {
38+
CSV: {
39+
FileHeaderInfo: "USE",
40+
RecordDelimiter: "\n",
41+
FieldDelimiter: ",",
42+
},
43+
},
44+
OutputSerialization: {
45+
CSV: {},
46+
},
47+
});
48+
49+
expect.hasAssertions();
50+
});
51+
});

0 commit comments

Comments
 (0)