mirror of https://github.com/buster-so/buster.git
Fix max-rows-limiting test mocks for streaming implementation
- Update Snowflake adapter test to use streamResult: true - Mock streamRows method with proper stream event handling - Remove TypeScript error from destroyed property - Verify streamRows called with correct start/end parameters Co-Authored-By: Dallin Bentley <dallinbentley98@gmail.com>
This commit is contained in:
parent
315a151a3f
commit
efd56f90a7
|
@ -218,7 +218,6 @@ describe('MaxRows Limiting Tests', () => {
|
||||||
mockStream = {
|
mockStream = {
|
||||||
on: vi.fn(),
|
on: vi.fn(),
|
||||||
destroy: vi.fn(),
|
destroy: vi.fn(),
|
||||||
destroyed: false,
|
|
||||||
};
|
};
|
||||||
mockConnection = {
|
mockConnection = {
|
||||||
execute: vi.fn(),
|
execute: vi.fn(),
|
||||||
|
@ -247,21 +246,26 @@ describe('MaxRows Limiting Tests', () => {
|
||||||
(options: {
|
(options: {
|
||||||
sqlText: string;
|
sqlText: string;
|
||||||
binds?: unknown;
|
binds?: unknown;
|
||||||
complete: (err?: unknown, stmt?: unknown, rows?: unknown[]) => void;
|
streamResult?: boolean;
|
||||||
|
complete: (err?: unknown, stmt?: unknown) => void;
|
||||||
}) => {
|
}) => {
|
||||||
// The new Snowflake adapter doesn't use streaming for maxRows
|
expect(options.streamResult).toBe(true);
|
||||||
// It returns all rows and limits in memory
|
options.complete(undefined, mockStatement);
|
||||||
options.complete(undefined, mockStatement, [
|
|
||||||
{ id: 1, name: 'User 1' },
|
|
||||||
{ id: 2, name: 'User 2' },
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await adapter.query('SELECT * FROM users', undefined, 1);
|
const queryPromise = adapter.query('SELECT * FROM users', undefined, 1);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
dataHandler({ id: 1, name: 'User 1' });
|
||||||
|
endHandler();
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
const result = await queryPromise;
|
||||||
expect(result.rows).toHaveLength(1);
|
expect(result.rows).toHaveLength(1);
|
||||||
expect(result.rows[0]).toEqual({ id: 1, name: 'User 1' });
|
expect(result.rows[0]).toEqual({ id: 1, name: 'User 1' });
|
||||||
expect(result.hasMoreRows).toBe(true);
|
expect(result.hasMoreRows).toBe(true);
|
||||||
|
expect(mockStatement.streamRows).toHaveBeenCalledWith({ start: 0, end: 1 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue