smartclickhouse/test/test.ts

40 lines
1015 B
TypeScript
Raw Normal View History

2022-03-07 14:49:47 +00:00
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
2022-03-14 13:29:23 +00:00
import * as smartclickhouse from '../ts/index.js';
2022-03-07 14:49:47 +00:00
let testClickhouseDb: smartclickhouse.SmartClickHouseDb;
tap.test('first test', async () => {
testClickhouseDb = new smartclickhouse.SmartClickHouseDb({
2022-07-27 20:42:08 +00:00
url: 'http://localhost:8123',
2022-03-07 14:49:47 +00:00
database: 'test2',
2022-07-30 16:03:17 +00:00
unref: true,
2022-03-07 14:49:47 +00:00
});
});
tap.test('should start the clickhouse db', async () => {
await testClickhouseDb.start(true);
});
2022-07-27 20:42:08 +00:00
tap.test('should create a timedatatable', async (toolsArg) => {
2022-03-07 14:49:47 +00:00
const table = await testClickhouseDb.getTable('analytics');
let i = 0;
2022-07-27 20:42:08 +00:00
while(i < 5000) {
2022-03-07 14:49:47 +00:00
await table.addData({
timestamp: Date.now(),
message: `hello this is a message ${i}`,
wow: 'hey',
deep: {
2022-03-08 14:12:51 +00:00
so: 'hello',
myArray: ['array1', 'array2']
2022-03-07 14:49:47 +00:00
}
});
i++;
2022-07-27 20:42:08 +00:00
console.log(`logged ${i} of 5000 lines.`);
await toolsArg.delayFor(1);
2022-03-07 14:49:47 +00:00
}
});
tap.skip.test('should write something to the clickhouse db', async () => {});
tap.start();