gongxiangp2/lib/__tests__/prisma-config.test.ts
chenpei 4e89b57798 feat(upload): optimize upload UI and performance
- Expand batch upload list area and optimize preview image layout
- Improve upload speed tracking and display (server-side & client-side)
- Reduce network detection log noise
- Optimize Docker build process (caching, env validation)
- Add shadow environment deployment support
2026-01-28 15:07:50 +08:00

54 lines
1.6 KiB
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.

/**
* R9/R35 测试:Prisma 连接池配置
*
* 验证:
* 1. 生产环境只记录 error 和 warn
* 2. 开发环境记录 query、error、warn
*/
describe('R9/R35: Prisma 连接池配置', () => {
// 保存原始环境变量
const originalEnv = process.env.NODE_ENV
afterEach(() => {
// 恢复环境变量
process.env.NODE_ENV = originalEnv
// 清除模块缓存
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')
})
})