Skip to content

Commit d34b96b

Browse files
committed
added unit tests with lz4 disabled
1 parent 40edb72 commit d34b96b

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

tests/unit/result/ArrowResultHandler.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ const sampleRowSet4: TRowSet = {
6666
],
6767
};
6868

69+
declare global {
70+
var LZ4: typeof import('lz4') | undefined; // Declare LZ4 on globalThis with proper type
71+
}
72+
6973
describe('ArrowResultHandler', () => {
7074
it('should return data', async () => {
7175
const rowSetProvider = new ResultsProviderStub([sampleRowSet1], undefined);
@@ -229,4 +233,17 @@ describe('ArrowResultHandler', () => {
229233
});
230234
expect(await result.hasMore()).to.be.false;
231235
});
236+
237+
it('should handle data without LZ4 compression', async () => {
238+
const rowSetProvider = new ResultsProviderStub([sampleRowSet1], undefined);
239+
const result = new ArrowResultHandler(new ClientContextStub(), rowSetProvider, {
240+
status: { statusCode: TStatusCode.SUCCESS_STATUS },
241+
arrowSchema: sampleArrowSchema,
242+
lz4Compressed: false,
243+
});
244+
245+
const { batches } = await result.fetchNext({ limit: 10000 });
246+
const expectedBatches = sampleRowSet1.arrowBatches?.map(({ batch }) => batch) ?? []; // Ensure iterable
247+
expect(batches).to.deep.eq([sampleArrowSchema, ...expectedBatches]);
248+
});
232249
});

tests/unit/result/CloudFetchResultHandler.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,24 @@ describe('CloudFetchResultHandler', () => {
379379
expect(context.invokeWithRetryStub.callCount).to.be.equal(1);
380380
}
381381
});
382+
383+
it('should handle data without LZ4 compression', async () => {
384+
const context = new ClientContextStub();
385+
const rowSetProvider = new ResultsProviderStub([sampleRowSet1], undefined);
386+
387+
const result = new CloudFetchResultHandler(context, rowSetProvider, {
388+
lz4Compressed: false,
389+
status: { statusCode: TStatusCode.SUCCESS_STATUS },
390+
});
391+
392+
context.invokeWithRetryStub.callsFake(async () => ({
393+
request: new Request('localhost'),
394+
response: new Response(sampleArrowBatch, { status: 200 }), // Return only the batch
395+
}));
396+
397+
const { batches } = await result.fetchNext({ limit: 10000 });
398+
399+
// Ensure the batches array matches the expected structure
400+
expect(batches).to.deep.eq([sampleArrowBatch]);
401+
});
382402
});

0 commit comments

Comments
 (0)