11import { S3 } from "@aws-sdk/client-s3" ;
2+ import { HttpResponse } from "@smithy/protocol-http" ;
23import { describe , expect , test as it } from "vitest" ;
34
45import { requireRequestsFrom } from "../../../../private/aws-util-test/src" ;
@@ -12,24 +13,31 @@ describe("selectObjectContent", () => {
1213 it ( "should make correct request" , async ( ) => {
1314 const client = new S3 ( { region : "us-west-2" , credentials } ) ;
1415
15- requireRequestsFrom ( client ) . toMatch ( {
16- hostname : / a w s - s d k - j s - i n t e g - t e s t - b u c k e t \. s 3 \. u s - w e s t - 2 \. a m a z o n a w s \. c o m / ,
17- method : "POST" ,
18- path : "/test-key" ,
19- headers : {
20- authorization : / A W S 4 - H M A C - S H A 2 5 6 C r e d e n t i a l / ,
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) > 20</Expression>"
27- ) ;
28- expect ( xmlBody ) . toContain ( "<ExpressionType>SQL</ExpressionType>" ) ;
29- } ,
30- } ) ;
16+ requireRequestsFrom ( client )
17+ . toMatch ( {
18+ hostname : / a w s - s d k - j s - i n t e g - t e s t - b u c k e t \. s 3 \. u s - w e s t - 2 \. a m a z o n a w s \. c o m / ,
19+ method : "POST" ,
20+ path : "/test-key" ,
21+ headers : {
22+ authorization : / A W S 4 - H M A C - S H A 2 5 6 C r e d e n t i a l / ,
23+ "content-type" : "application/xml" ,
24+ "x-amz-content-sha256" : / ./ ,
25+ } ,
26+ body ( xmlBody ) {
27+ expect ( xmlBody ) . toContain (
28+ "<Expression>SELECT user_name FROM S3Object WHERE cast(age as int) > 20</Expression>"
29+ ) ;
30+ expect ( xmlBody ) . toContain ( "<ExpressionType>SQL</ExpressionType>" ) ;
31+ } ,
32+ } )
33+ . respondWith (
34+ new HttpResponse ( {
35+ statusCode : 200 ,
36+ body : " " ,
37+ } )
38+ ) ;
3139
32- await client . selectObjectContent ( {
40+ const response = await client . selectObjectContent ( {
3341 Bucket : "aws-sdk-js-integ-test-bucket" ,
3442 Key : "test-key" ,
3543 ExpressionType : "SQL" ,
@@ -47,5 +55,9 @@ describe("selectObjectContent", () => {
4755 } ) ;
4856
4957 expect . hasAssertions ( ) ;
58+ expect ( response ) . toHaveProperty ( "$metadata" ) ;
59+ expect ( response . $metadata . httpStatusCode ) . toBe ( 200 ) ;
60+ expect ( response ) . toHaveProperty ( "Payload" ) ;
61+ expect ( response . Payload ) . toBeDefined ( ) ;
5062 } ) ;
5163} ) ;
0 commit comments