Skip to content

Commit

Permalink
fix(ci): add beforeAll to force create needed system tables
Browse files Browse the repository at this point in the history
  • Loading branch information
duyet committed Nov 29, 2024
1 parent 8f7579d commit 97fd6bb
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion app/[host]/[query]/query-config.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand All @@ -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 }) => {
Expand Down

0 comments on commit 97fd6bb

Please sign in to comment.