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:
Devin AI 2025-07-23 14:12:25 +00:00
parent 315a151a3f
commit efd56f90a7
1 changed files with 13 additions and 9 deletions

View File

@ -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 });
}); });
}); });