Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Levko Kravets <[email protected]>
  • Loading branch information
kravets-levko committed Aug 3, 2023
1 parent f12ac0f commit cff71f8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
2 changes: 2 additions & 0 deletions lib/DBSQLOperation/FetchResultsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export default class FetchResultsHelper {

this.pendingResults.push(responseFragment);
}
} else {
this.pendingResults.push(response);
}
}
}
2 changes: 1 addition & 1 deletion tests/e2e/arrow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('Arrow support', () => {
// but with much enough rows there should be more than one result batch
expect(rawData.arrowBatches?.length).to.be.gt(1);

const result = resultHandler.getValue([rawData]);
const result = await resultHandler.getValue([rawData]);
expect(result.length).to.be.eq(rowsCount);
});
});
20 changes: 10 additions & 10 deletions tests/unit/result/ArrowResult.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ const sampleRowSet4 = {
};

describe('ArrowResult', () => {
it('should convert data', () => {
it('should convert data', async () => {
const result = new ArrowResult(sampleThriftSchema, sampleArrowSchema);
expect(result.getValue([sampleRowSet1])).to.be.deep.eq([]);
expect(result.getValue([sampleRowSet2])).to.be.deep.eq([]);
expect(result.getValue([sampleRowSet3])).to.be.deep.eq([]);
expect(result.getValue([sampleRowSet4])).to.be.deep.eq([{ 1: 1 }]);
expect(await result.getValue([sampleRowSet1])).to.be.deep.eq([]);
expect(await result.getValue([sampleRowSet2])).to.be.deep.eq([]);
expect(await result.getValue([sampleRowSet3])).to.be.deep.eq([]);
expect(await result.getValue([sampleRowSet4])).to.be.deep.eq([{ 1: 1 }]);
});

it('should return empty array if no data to process', () => {
it('should return empty array if no data to process', async () => {
const result = new ArrowResult(sampleThriftSchema, sampleArrowSchema);
expect(result.getValue()).to.be.deep.eq([]);
expect(result.getValue([])).to.be.deep.eq([]);
expect(await result.getValue()).to.be.deep.eq([]);
expect(await result.getValue([])).to.be.deep.eq([]);
});

it('should return empty array if no schema available', () => {
it('should return empty array if no schema available', async () => {
const result = new ArrowResult();
expect(result.getValue([sampleRowSet4])).to.be.deep.eq([]);
expect(await result.getValue([sampleRowSet4])).to.be.deep.eq([]);
});
});
30 changes: 15 additions & 15 deletions tests/unit/result/JsonResult.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getColumnSchema = (columnName, type, position) => {
};

describe('JsonResult', () => {
it('should convert schema with primitive types to json', () => {
it('should convert schema with primitive types to json', async () => {
const schema = {
columns: [
getColumnSchema('table.str', TCLIService_types.TTypeId.STRING_TYPE, 1),
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('JsonResult', () => {

const result = new JsonResult(schema);

expect(result.getValue(data)).to.be.deep.eq([
expect(await result.getValue(data)).to.be.deep.eq([
{
'table.str': 'a',
'table.int64': 282578800148737,
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('JsonResult', () => {
]);
});

it('should convert complex types', () => {
it('should convert complex types', async () => {
const schema = {
columns: [
getColumnSchema('table.array', TCLIService_types.TTypeId.ARRAY_TYPE, 1),
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('JsonResult', () => {

const result = new JsonResult(schema);

expect(result.getValue(data)).to.be.deep.eq([
expect(await result.getValue(data)).to.be.deep.eq([
{
'table.array': ['a', 'b'],
'table.map': { key: 12 },
Expand All @@ -197,7 +197,7 @@ describe('JsonResult', () => {
]);
});

it('should merge data items', () => {
it('should merge data items', async () => {
const schema = {
columns: [getColumnSchema('table.id', TCLIService_types.TTypeId.STRING_TYPE, 1)],
};
Expand All @@ -221,7 +221,7 @@ describe('JsonResult', () => {

const result = new JsonResult(schema);

expect(result.getValue(data)).to.be.deep.eq([
expect(await result.getValue(data)).to.be.deep.eq([
{ 'table.id': '0' },
{ 'table.id': '1' },
{ 'table.id': '2' },
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('JsonResult', () => {
});
});

it('should detect nulls for each type', () => {
it('should detect nulls for each type', async () => {
const schema = {
columns: [
getColumnSchema('table.str', TCLIService_types.TTypeId.STRING_TYPE, 1),
Expand Down Expand Up @@ -344,7 +344,7 @@ describe('JsonResult', () => {

const result = new JsonResult(schema);

expect(result.getValue(data)).to.be.deep.eq([
expect(await result.getValue(data)).to.be.deep.eq([
{
'table.str': null,
'table.int64': null,
Expand All @@ -366,18 +366,18 @@ describe('JsonResult', () => {
]);
});

it('should return empty array if no data to process', () => {
it('should return empty array if no data to process', async () => {
const schema = {
columns: [getColumnSchema('table.id', TCLIService_types.TTypeId.STRING_TYPE, 1)],
};

const result = new JsonResult(schema);

expect(result.getValue()).to.be.deep.eq([]);
expect(result.getValue([])).to.be.deep.eq([]);
expect(await result.getValue()).to.be.deep.eq([]);
expect(await result.getValue([])).to.be.deep.eq([]);
});

it('should return empty array if no schema available', () => {
it('should return empty array if no schema available', async () => {
const data = [
{
columns: [
Expand All @@ -390,10 +390,10 @@ describe('JsonResult', () => {

const result = new JsonResult();

expect(result.getValue(data)).to.be.deep.eq([]);
expect(await result.getValue(data)).to.be.deep.eq([]);
});

it('should return raw data if types are not specified', () => {
it('should return raw data if types are not specified', async () => {
const schema = {
columns: [
getColumnSchema('table.array', undefined, 1),
Expand Down Expand Up @@ -423,7 +423,7 @@ describe('JsonResult', () => {

const result = new JsonResult(schema);

expect(result.getValue(data)).to.be.deep.eq([
expect(await result.getValue(data)).to.be.deep.eq([
{
'table.array': '["a", "b"]',
'table.map': '{ "key": 12 }',
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/result/compatibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ const fixtureArrow = require('../../fixtures/compatibility/arrow');
const fixtureArrowNT = require('../../fixtures/compatibility/arrow_native_types');

describe('Result handlers compatibility tests', () => {
it('colum-based data', () => {
it('colum-based data', async () => {
const result = new JsonResult(fixtureColumn.schema);
const rows = result.getValue(fixtureColumn.rowSets);
const rows = await result.getValue(fixtureColumn.rowSets);
expect(rows).to.deep.equal(fixtureColumn.expected);
});

it('arrow-based data without native types', () => {
it('arrow-based data without native types', async () => {
const result = new ArrowResult(fixtureArrow.schema, fixtureArrow.arrowSchema);
const rows = result.getValue(fixtureArrow.rowSets);
const rows = await result.getValue(fixtureArrow.rowSets);
expect(fixArrowResult(rows)).to.deep.equal(fixtureArrow.expected);
});

it('arrow-based data with native types', () => {
it('arrow-based data with native types', async () => {
const result = new ArrowResult(fixtureArrowNT.schema, fixtureArrowNT.arrowSchema);
const rows = result.getValue(fixtureArrowNT.rowSets);
const rows = await result.getValue(fixtureArrowNT.rowSets);
expect(fixArrowResult(rows)).to.deep.equal(fixtureArrowNT.expected);
});
});

0 comments on commit cff71f8

Please sign in to comment.