Files
cms-website/apps/api/test/db.connect.test.ts
T
2026-10-20 18:56:50 +08:00

13 lines
477 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect } from 'vitest'
import { getDb } from '../src/db/client.js'
describe('数据库连接', () => {
it('连接本项目 PG(5434)并响应 select 1', async () => {
const db = getDb()
// postgres.js 驱动下 drizzle 的 execute 返回 RowList(行数组),
// 不是 node-postgres 风格的 { rows: [...] },故直接取 r[0]
const r = (await db.execute('select 1 as ok')) as any
expect(Number(r[0].ok)).toBe(1)
})
})