From efd56f90a70a85ba0b0629f060f2b45f6c735a6b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 14:12:25 +0000 Subject: [PATCH] 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 --- .../src/adapters/max-rows-limiting.test.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/data-source/src/adapters/max-rows-limiting.test.ts b/packages/data-source/src/adapters/max-rows-limiting.test.ts index e44a360d3..38994b34b 100644 --- a/packages/data-source/src/adapters/max-rows-limiting.test.ts +++ b/packages/data-source/src/adapters/max-rows-limiting.test.ts @@ -218,7 +218,6 @@ describe('MaxRows Limiting Tests', () => { mockStream = { on: vi.fn(), destroy: vi.fn(), - destroyed: false, }; mockConnection = { execute: vi.fn(), @@ -247,21 +246,26 @@ describe('MaxRows Limiting Tests', () => { (options: { sqlText: string; 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 - // It returns all rows and limits in memory - options.complete(undefined, mockStatement, [ - { id: 1, name: 'User 1' }, - { id: 2, name: 'User 2' }, - ]); + expect(options.streamResult).toBe(true); + options.complete(undefined, mockStatement); } ); - 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[0]).toEqual({ id: 1, name: 'User 1' }); expect(result.hasMoreRows).toBe(true); + expect(mockStatement.streamRows).toHaveBeenCalledWith({ start: 0, end: 1 }); }); });