gongxiangp2/lib/__tests__/prisma-config.test.ts
chenpei 4712175cb0 feat(素材链路): 发布白底图双轨与AI生图回传能力
- 完成白底图 WebP 双轨接口、上传链路与预览缓存改造
- 新增 AI 生图平台成品回传接口、任务状态与表单规则
- 补齐 AI 生成标签、任务详情补全、相关测试与对接文档
2026-03-25 10:28:02 +08:00

49 lines
1.5 KiB
TypeScript
Raw Permalink 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.

/**
* R9/R35 测试:Prisma 连接池配置
*
* 验证:
* 1. 生产环境只记录 error 和 warn
* 2. 开发环境记录 query、error、warn
*/
describe('R9/R35: Prisma 连接池配置', () => {
afterEach(() => {
// 清除模块缓存
jest.resetModules()
})
it('生产环境应该只记录 error 和 warn', () => {
// 读取 prisma.ts 源代码,检查配置逻辑
const fs = require('fs')
const path = require('path')
const prismaPath = path.join(__dirname, '..', 'prisma.ts')
const content = fs.readFileSync(prismaPath, 'utf-8')
// 验证生产环境日志配置
expect(content).toContain("process.env.NODE_ENV === 'production'")
expect(content).toContain("['error', 'warn']")
})
it('开发环境应该记录 query、error、warn', () => {
const fs = require('fs')
const path = require('path')
const prismaPath = path.join(__dirname, '..', 'prisma.ts')
const content = fs.readFileSync(prismaPath, 'utf-8')
// 验证开发环境日志配置
expect(content).toContain("['query', 'error', 'warn']")
})
it('应该有连接池配置说明', () => {
const fs = require('fs')
const path = require('path')
const prismaPath = path.join(__dirname, '..', 'prisma.ts')
const content = fs.readFileSync(prismaPath, 'utf-8')
// 验证有连接池配置说明
expect(content).toContain('R9/R35修复')
expect(content).toContain('connection_limit')
expect(content).toContain('pool_timeout')
})
})