Skip to content

Commit

Permalink
update httpfs test.
Browse files Browse the repository at this point in the history
  • Loading branch information
e1arikawa committed Sep 21, 2024
1 parent caaf8ad commit 0977660
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/duckdb-wasm/test/httpfs_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as duckdb from '../src/';
import { getS3Params, S3Params, S3PayloadParams, createS3Headers, uriEncode, getHTTPUrl } from '../src/utils';
import { AsyncDuckDBConnection, DuckDBBindings, DuckDBBindingsBase, DuckDBModule } from '../src/';
import BROWSER_RUNTIME from '../src/bindings/runtime_browser';
import {generateRandomString} from "./string_test_helper";
import {generateLongQueryString} from "./string_test_helper";

// S3 config for tests
const BUCKET_NAME = 'test-bucket';
Expand Down Expand Up @@ -314,19 +314,18 @@ export function testHTTPFSAsync(
).toBeRejectedWithError('Invalid Error: File is not opened in write mode');
});


it('can read parquet file from URL with long query string', async () => {
const queryString = generateRandomString(1500);
const queryString = generateLongQueryString();
const result = await conn!.query(
`select * from "${S3_ENDPOINT}/${BUCKET_NAME}/correct_auth_test.parquet?${queryString}";`,
`SELECT * FROM "${S3_ENDPOINT}/${BUCKET_NAME}/correct_auth_test.parquet?${queryString}";`,
);
expect(Number((result.getChildAt(0)?.get(6)))).toEqual(Number(29120));
});

it('can read csv file from URL with long query string', async () => {
const queryString = generateRandomString(1500);
const queryString = generateLongQueryString();
const result = await conn!.query(
`select * from "${S3_ENDPOINT}/${BUCKET_NAME}/correct_auth_test.csv?${queryString}";`,
`SELECT * FROM "${S3_ENDPOINT}/${BUCKET_NAME}/correct_auth_test.csv?${queryString}";`,
);
expect(Number((result.getChildAt(0)?.get(6)))).toEqual(Number(29120));
});
Expand Down
17 changes: 17 additions & 0 deletions packages/duckdb-wasm/test/string_test_helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
export function generateLongQueryString(): string {
const aaa = generateRandomString(512);
const ddd = generateRandomString(512);
const ccc = generateRandomString(256);
const eee = generateRandomString(128);
const ggg = generateRandomString(64);
const hhh = generateRandomString(32);

return `T=Long` +
`&T-AAA=${aaa}` +
`&T-CCC=${ccc}` +
`&T-DDD=${ddd}` +
`&T-EEE=${eee}` +
`&T-GGG=${ggg}` +
`&T-HHH=${hhh}`;
}

export function generateRandomString(length: number): string {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
Expand Down

0 comments on commit 0977660

Please sign in to comment.