Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 1 addition & 45 deletions clients/client-s3/test/e2e/S3.browser.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { S3, SelectObjectContentEventStream, waitUntilObjectExists } from "@aws-sdk/client-s3";
import type { S3, waitUntilObjectExists } from "@aws-sdk/client-s3";
import { fromNodeProviderChain } from "@aws-sdk/credential-providers";
import { FetchHttpHandler } from "@smithy/fetch-http-handler";
import { Browser } from "happy-dom";
Expand Down Expand Up @@ -315,50 +315,6 @@ describe("@aws-sdk/client-s3", () => {
});
});

describe("selectObjectContent", () => {
const csvFile = `user_name,age
jsrocks,13
node4life,22
esfuture,29`;

beforeEach(async () => {
Key = `${Date.now()}`;
await client.putObject({ Bucket, Key, Body: csvFile });
});

afterEach(async () => {
await client.deleteObject({ Bucket, Key });
});

it("should succeed", async () => {
onTestFailed(setTestFailed);
const { Payload } = await client.selectObjectContent({
Bucket,
Key,
ExpressionType: "SQL",
Expression: "SELECT user_name FROM S3Object WHERE cast(age as int) > 20",
InputSerialization: {
CSV: {
FileHeaderInfo: "USE",
RecordDelimiter: "\n",
FieldDelimiter: ",",
},
},
OutputSerialization: {
CSV: {},
},
});
const events: SelectObjectContentEventStream[] = [];
for await (const event of Payload!) {
events.push(event);
}
expect(events.length).toEqual(3);
expect(new TextDecoder().decode(events[0].Records?.Payload)).toEqual("node4life\nesfuture\n");
expect(events[1].Stats?.Details).toBeDefined();
expect(events[2].End).toBeDefined();
});
});

describe("Multi-region access point", () => {
beforeEach(async () => {
Key = `${Date.now()}`;
Expand Down
42 changes: 1 addition & 41 deletions clients/client-s3/test/e2e/S3.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@aws-sdk/signature-v4-crt";

import { ChecksumAlgorithm, S3, SelectObjectContentEventStream } from "@aws-sdk/client-s3";
import { ChecksumAlgorithm, S3 } from "@aws-sdk/client-s3";
import { afterAll, afterEach, beforeAll, describe, expect, test as it } from "vitest";

import { getIntegTestResources } from "../../../../tests/e2e/get-integ-test-resources";
Expand Down Expand Up @@ -231,46 +231,6 @@ describe("@aws-sdk/client-s3", () => {
});
});

describe("selectObjectContent", () => {
const csvFile = `user_name,age
jsrocks,13
node4life,22
esfuture,29`;
beforeAll(async () => {
Key = `${Date.now()}`;
await client.putObject({ Bucket, Key, Body: csvFile });
});
afterAll(async () => {
await client.deleteObject({ Bucket, Key });
});
it("should succeed", async () => {
const { Payload } = await client.selectObjectContent({
Bucket,
Key,
ExpressionType: "SQL",
Expression: "SELECT user_name FROM S3Object WHERE cast(age as int) > 20",
InputSerialization: {
CSV: {
FileHeaderInfo: "USE",
RecordDelimiter: "\n",
FieldDelimiter: ",",
},
},
OutputSerialization: {
CSV: {},
},
});
const events: SelectObjectContentEventStream[] = [];
for await (const event of Payload!) {
events.push(event);
}
expect(events.length).toEqual(3);
expect(new TextDecoder().decode(events[0].Records?.Payload)).toEqual("node4life\nesfuture\n");
expect(events[1].Stats?.Details).toBeDefined();
expect(events[2].End).toBeDefined();
});
});

describe("Multi-region access point", () => {
beforeAll(async () => {
Key = `${Date.now()}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { S3 } from "@aws-sdk/client-s3";
import { HttpResponse } from "@smithy/protocol-http";
import { describe, expect, test as it } from "vitest";

import { requireRequestsFrom } from "../../../../private/aws-util-test/src";

describe("selectObjectContent", () => {
const credentials = {
accessKeyId: "INTEG",
secretAccessKey: "INTEG",
};

it("should make correct request", async () => {
const client = new S3({ region: "us-west-2", credentials });

requireRequestsFrom(client)
.toMatch({
hostname: /aws-sdk-js-integ-test-bucket\.s3\.us-west-2\.amazonaws\.com/,
method: "POST",
path: "/test-key",
headers: {
authorization: /AWS4-HMAC-SHA256 Credential/,
"content-type": "application/xml",
"x-amz-content-sha256": /./,
},
body(xmlBody) {
expect(xmlBody).toContain(
"<Expression>SELECT user_name FROM S3Object WHERE cast(age as int) &gt; 20</Expression>"
);
expect(xmlBody).toContain("<ExpressionType>SQL</ExpressionType>");
},
})
.respondWith(
new HttpResponse({
statusCode: 200,
body: " ",
})
);

const response = await client.selectObjectContent({
Bucket: "aws-sdk-js-integ-test-bucket",
Key: "test-key",
ExpressionType: "SQL",
Expression: "SELECT user_name FROM S3Object WHERE cast(age as int) > 20",
InputSerialization: {
CSV: {
FileHeaderInfo: "USE",
RecordDelimiter: "\n",
FieldDelimiter: ",",
},
},
OutputSerialization: {
CSV: {},
},
});

expect.hasAssertions();
expect(response).toHaveProperty("$metadata");
expect(response.$metadata.httpStatusCode).toBe(200);
expect(response).toHaveProperty("Payload");
expect(response.Payload).toBeDefined();
});
});
Loading