fix(core): update
This commit is contained in:
@ -16,7 +16,7 @@ tap.test('should start the clickhouse db', async () => {
|
||||
await testClickhouseDb.start(true);
|
||||
});
|
||||
|
||||
tap.test('should create a timedatatable', async (toolsArg) => {
|
||||
tap.test('should create a timedatatable', async () => {
|
||||
table = await testClickhouseDb.getTable('analytics');
|
||||
let i = 0;
|
||||
while (i < 1000) {
|
||||
@ -49,19 +49,37 @@ tap.test('should retrieve entries newer than a specific timestamp', async () =>
|
||||
|
||||
tap.test('should retrieve entries between two timestamps', async () => {
|
||||
const startTimestamp = Date.now() - 120000; // 2 minutes ago
|
||||
const endTimestamp = Date.now() - 60000; // 1 minute ago
|
||||
const endTimestamp = Date.now() - 5000; // 5 seconds ago
|
||||
const entries = await table.getEntriesBetween(startTimestamp, endTimestamp);
|
||||
expect(entries.length).toBeGreaterThan(0);
|
||||
console.log(entries);
|
||||
});
|
||||
|
||||
tap.test('should delete old entries', async () => {
|
||||
tap.test('should delete old entries', async (toolsArg) => {
|
||||
// Ensure there are entries before deletion
|
||||
let entries = await table.getLastEntries(1000);
|
||||
expect(entries.length).toBeGreaterThan(100);
|
||||
console.log('Entries before deletion:', entries.length);
|
||||
|
||||
await table.deleteOldEntries(0); // Delete all entries older than now
|
||||
const entries = await table.getLastEntries(10);
|
||||
expect(entries.length).toEqual(0);
|
||||
// Add a delay to ensure the delete operation completes
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
|
||||
// Verify the entries are deleted
|
||||
entries = await table.getLastEntries(1000);
|
||||
console.log('Entries after deletion:', entries.length);
|
||||
expect(entries.length).toBeLessThan(100);
|
||||
await toolsArg.delayFor(5000);
|
||||
});
|
||||
|
||||
tap.test('should delete the table', async () => {
|
||||
await table.delete();
|
||||
// Verify table deletion
|
||||
const result = await testClickhouseDb.clickhouseHttpClient.queryPromise(`
|
||||
SHOW TABLES FROM ${testClickhouseDb.options.database} LIKE '${table.options.tableName}'
|
||||
`);
|
||||
console.log('Table exists after deletion:', result);
|
||||
expect(result.length).toEqual(0);
|
||||
});
|
||||
|
||||
tap.test('should stream new entries', async (toolsArg) => {
|
||||
|
Reference in New Issue
Block a user