- dacli/ 整目录被 .gitignore 忽略,本次 force-add 其业务源码(766 文件) - 排除 node_modules/.env(含 PGPASSWORD 等敏感信息)/.DS_Store/__pycache__/*.pyc - 新增 dacli/.gitignore 长期管理内部噪声,新增文件仍需 git add -f - 根 .gitignore 补充 .cache/ 与诊断脚本忽略,并加 dacli 段说明
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
/**
|
|
* proxy.test.ts — dacli proxy subcommand (mock execSync)
|
|
*/
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
|
|
vi.mock('node:child_process', () => ({
|
|
execSync: vi.fn(() => ''),
|
|
spawn: vi.fn(() => ({ on: vi.fn() })),
|
|
}))
|
|
|
|
describe('dacli proxy subcommand', () => {
|
|
beforeEach(() => vi.clearAllMocks())
|
|
|
|
it('proxy up calls scripts/proxy-up.sh', async () => {
|
|
const { runProxy } = await import('../../../src/commands/proxy/index.ts')
|
|
const code = await runProxy(['up'])
|
|
expect(code).toBe(0)
|
|
const { execSync } = await import('node:child_process')
|
|
expect(execSync).toHaveBeenCalledWith(expect.stringContaining('proxy-up.sh'), expect.any(Object))
|
|
})
|
|
|
|
it('proxy down calls scripts/proxy-down.sh', async () => {
|
|
const { runProxy } = await import('../../../src/commands/proxy/index.ts')
|
|
const code = await runProxy(['down'])
|
|
expect(code).toBe(0)
|
|
const { execSync } = await import('node:child_process')
|
|
expect(execSync).toHaveBeenCalledWith(expect.stringContaining('proxy-down.sh'), expect.any(Object))
|
|
})
|
|
|
|
it('proxy status runs curl health check', async () => {
|
|
const { execSync } = await import('node:child_process')
|
|
vi.mocked(execSync).mockReturnValueOnce('200' as any)
|
|
const { runProxy } = await import('../../../src/commands/proxy/index.ts')
|
|
const code = await runProxy(['status'])
|
|
expect(code).toBe(0)
|
|
})
|
|
|
|
it('unknown sub fails', async () => {
|
|
const { runProxy } = await import('../../../src/commands/proxy/index.ts')
|
|
const code = await runProxy(['bogus'])
|
|
expect(code).toBe(1)
|
|
})
|
|
}) |