-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare 0.2.9; Cleanup tests and restrict the headers type to string …
…only
- Loading branch information
Showing
15 changed files
with
737 additions
and
798 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
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 +1 @@ | ||
export default '0.2.8' | ||
export default '0.2.9' |
55 changes: 55 additions & 0 deletions
55
packages/client-node/__tests__/integration/node_client.test.ts
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 Http from 'http' | ||
import type Stream from 'stream' | ||
import type { ClickHouseClient } from '../../src' | ||
import { createClient } from '../../src' | ||
import { emitResponseBody, stubClientRequest } from '../utils/http_stubs' | ||
|
||
describe('[Node.js] Client', () => { | ||
let httpRequestStub: jasmine.Spy<typeof Http.request> | ||
let clientRequest: Http.ClientRequest | ||
beforeEach(() => { | ||
clientRequest = stubClientRequest() | ||
httpRequestStub = spyOn(Http, 'request').and.returnValue(clientRequest) | ||
}) | ||
|
||
describe('Additional headers', () => { | ||
it('should be possible to set additional_headers', async () => { | ||
const client = createClient({ | ||
additional_headers: { | ||
'Test-Header': 'foobar', | ||
}, | ||
}) | ||
await query(client) | ||
|
||
expect(httpRequestStub).toHaveBeenCalledTimes(1) | ||
const calledWith = httpRequestStub.calls.mostRecent().args[1] | ||
expect(calledWith.headers).toEqual({ | ||
Authorization: 'Basic ZGVmYXVsdDo=', // default user with empty password | ||
'Accept-Encoding': 'gzip', | ||
'Test-Header': 'foobar', | ||
'User-Agent': jasmine.stringContaining('clickhouse-js'), | ||
}) | ||
}) | ||
|
||
it('should work without additional headers', async () => { | ||
const client = createClient({}) | ||
await query(client) | ||
|
||
expect(httpRequestStub).toHaveBeenCalledTimes(1) | ||
const calledWith = httpRequestStub.calls.mostRecent().args[1] | ||
expect(calledWith.headers).toEqual({ | ||
Authorization: 'Basic ZGVmYXVsdDo=', // default user with empty password | ||
'Accept-Encoding': 'gzip', | ||
'User-Agent': jasmine.stringContaining('clickhouse-js'), | ||
}) | ||
}) | ||
}) | ||
|
||
async function query(client: ClickHouseClient<Stream.Readable>) { | ||
const selectPromise = client.query({ | ||
query: 'SELECT * FROM system.numbers LIMIT 5', | ||
}) | ||
emitResponseBody(clientRequest, 'hi') | ||
await selectPromise | ||
} | ||
}) |
102 changes: 0 additions & 102 deletions
102
packages/client-node/__tests__/integration/node_connection.test.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.