Skip to content

Commit

Permalink
chore: add regression test for #448
Browse files Browse the repository at this point in the history
  • Loading branch information
ankoh committed Dec 7, 2021
1 parent 17570dc commit bfdf5d7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/duckdb-wasm/test/regression/github_448.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as duckdb from '../../src';
import * as arrow from 'apache-arrow';

// https://github.com/duckdb/duckdb-wasm/issues/448
export function test448(db: () => duckdb.AsyncDuckDB): void {
let conn: duckdb.AsyncDuckDBConnection | null = null;
beforeEach(async () => {
await db().flushFiles();
});
afterEach(async () => {
if (conn) {
await conn.close();
conn = null;
}
await db().flushFiles();
await db().dropFiles();
});
describe('GitHub issues', () => {
it('448', async () => {
conn = await db().connect();
await conn.query(`create temp table test448(i integer)`);
await conn.query(`insert into test448 values (1),(2),(1)`);
let result = await conn.query(`select * from test448`);
expect(result.numCols).toBe(1);
expect(result.length).toBe(3);
expect(result.getColumnAt(0)?.toArray()).toEqual(new Int32Array([1, 2, 1]));
result = await conn.query<{ i: arrow.Map_<arrow.Int32, arrow.Uint64> }>(`select histogram(i) from test448`);
expect(result.numCols).toBe(1);
expect(result.length).toBe(1);
const array = result.getColumnAt(0)!.toArray();
expect(array.length).toEqual(1);
expect(array[0].toString()).toEqual('{ 1: 2, 2: 1 }');
});
});
}
2 changes: 2 additions & 0 deletions packages/duckdb-wasm/test/regression/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import * as duckdb from '../../src/';
import { test332 } from './github_332.test';
import { test334 } from './github_334.test';
import { test393 } from './github_393.test';
import { test448 } from './github_448.test';

export function testRegressionAsync(adb: () => duckdb.AsyncDuckDB): void {
test332(adb);
test334(adb);
test393(adb);
test448(adb);
}

0 comments on commit bfdf5d7

Please sign in to comment.