From 97fd6bb91cc9c14ea5459e27784933d38c3735e4 Mon Sep 17 00:00:00 2001 From: Duyet Le Date: Fri, 29 Nov 2024 12:45:48 +0700 Subject: [PATCH] fix(ci): add beforeAll to force create needed system tables --- app/[host]/[query]/query-config.test.ts | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/[host]/[query]/query-config.test.ts b/app/[host]/[query]/query-config.test.ts index 1fd0294..716d7e9 100644 --- a/app/[host]/[query]/query-config.test.ts +++ b/app/[host]/[query]/query-config.test.ts @@ -1,5 +1,6 @@ +import { beforeAll, expect, test } from '@jest/globals' + import { fetchData } from '@/lib/clickhouse' -import { expect, test } from '@jest/globals' import { queries } from './clickhouse-queries' describe('query config', () => { @@ -11,6 +12,29 @@ describe('query config', () => { return { name: config.name, config } }) + beforeAll(async () => { + console.log('prepare data for system.error_log') + + try { + await fetchData({ + query: 'SELECT * FROM not_found_table_will_fail', + }) + } catch { + console.log('generated a record in system.error_log') + } + + try { + await fetchData({ + query: "BACKUP DATABASE default TO File('/tmp/backup')", + }) + } catch { + // Although the backup can be failed, it will generate a record in system.backup_log + // DB::Exception: Path '/tmp/backup' is not allowed for backups, + // see the 'backups.allowed_path' configuration parameter + console.log('generated a record in system.backup_log') + } + }) + test.each(namedConfig)( 'check if valid sql for $name config', async ({ name, config }) => {