fix(core): update
This commit is contained in:
41
test/test.ts
41
test/test.ts
@ -1,12 +1,12 @@
|
||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartclickhouse from '../ts/index';
|
||||
|
||||
let testClickhouseDb: smartclickhouse.ClickhouseDb;
|
||||
let testClickhouseDb: smartclickhouse.SmartClickHouseDb;
|
||||
|
||||
tap.test('first test', async () => {
|
||||
testClickhouseDb = new smartclickhouse.ClickhouseDb({
|
||||
url: 'http://localhost',
|
||||
port: 8123,
|
||||
testClickhouseDb = new smartclickhouse.SmartClickHouseDb({
|
||||
host: 'localhost',
|
||||
database: 'test2'
|
||||
});
|
||||
});
|
||||
|
||||
@ -14,32 +14,23 @@ tap.test('should start the clickhouse db', async () => {
|
||||
await testClickhouseDb.start();
|
||||
})
|
||||
|
||||
tap.test('should write something to the clickhouse db', async () => {
|
||||
const result = await testClickhouseDb.clickhouseClient.query(`CREATE DATABASE IF NOT EXISTS lossless`).toPromise();
|
||||
console.log(result);
|
||||
const result2 = await testClickhouseDb.clickhouseClient.query(`CREATE TABLE IF NOT EXISTS lossless.visits (
|
||||
tap.skip.test('should write something to the clickhouse db', async () => {
|
||||
const result2 = await testClickhouseDb.clickhouseClient.queryPromise(`CREATE TABLE IF NOT EXISTS visits2 (
|
||||
timestamp UInt64,
|
||||
ip String,
|
||||
os String,
|
||||
userAgent String,
|
||||
version String
|
||||
) ENGINE=MergeTree() ORDER BY timestamp`).toPromise();
|
||||
console.log(result2);
|
||||
const ws = testClickhouseDb.clickhouseClient.insert('INSERT INTO lossless.visits FORMAT JSONEachRow').stream();
|
||||
for(let i = 0; i <= 1000; i++) {
|
||||
await ws.writeRow(
|
||||
JSON.stringify({
|
||||
timestamp: Date.now(),
|
||||
ip: '127.0.01',
|
||||
os: 'Mac OS X',
|
||||
userAgent: 'some',
|
||||
version: 'someversion'
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
//wait stream finish
|
||||
const result3 = await ws.exec();
|
||||
) ENGINE=MergeTree() ORDER BY timestamp`);
|
||||
const result3 = await testClickhouseDb.clickhouseClient.insertPromise('visits2', [
|
||||
{
|
||||
timestamp: Date.now(),
|
||||
ip: '127.0.01',
|
||||
os: 'Mac OS X',
|
||||
userAgent: 'some',
|
||||
version: 'someversion'
|
||||
}
|
||||
]);
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user