-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
253 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
/* eslint-disable no-unused-vars */ | ||
export function voidLogger() { | ||
return { | ||
debug() {}, | ||
info() {}, | ||
log() {}, | ||
warn() {}, | ||
error() {} | ||
debug(..._) {}, | ||
info(..._) {}, | ||
log(..._) {}, | ||
warn(..._) {}, | ||
error(..._) {} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { QueryManager } from '../src/QueryManager.js'; | ||
import { QueryResult } from '../src/util/query-result.js'; | ||
|
||
describe('QueryManager', () => { | ||
it('should run a simple query', async () => { | ||
const queryManager = new QueryManager(); | ||
|
||
// Mock the connector | ||
queryManager.connector({ | ||
query: async ({ sql }) => { | ||
expect(sql).toBe('SELECT 1'); | ||
return [{ column: 1 }]; | ||
} | ||
}); | ||
|
||
const request = { | ||
type: 'arrow', | ||
query: 'SELECT 1' | ||
}; | ||
|
||
const result = queryManager.request(request); | ||
expect(result).toBeInstanceOf(QueryResult); | ||
|
||
const data = await result; | ||
expect(data).toEqual([{ column: 1 }]); | ||
}); | ||
|
||
it('should not run a query when there is a pending exec', async () => { | ||
const queryManager = new QueryManager(); | ||
|
||
// Mock the connector | ||
queryManager.connector({ | ||
query: async ({ sql }) => { | ||
expect(sql).toBe('CREATE TABLE test (id INT)'); | ||
Check failure on line 35 in packages/core/test/query-manager.test.js GitHub Actions / Test in NodeUnhandled error
|
||
return undefined; | ||
} | ||
}); | ||
|
||
const request1 = { | ||
type: 'exec', | ||
query: 'CREATE TABLE test (id INT)' | ||
}; | ||
|
||
const request2 = { | ||
type: 'arrow', | ||
query: 'SELECT * FROM test' | ||
}; | ||
|
||
queryManager.request(request1); | ||
queryManager.request(request2); | ||
|
||
expect(queryManager.pendingResults).toHaveLength(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters