本仓 2026-08-12 从 ssw main (192.168.1.18:13300/ssw/ssw-mvp) 的 dacli/ subpath 抽取,作为独立仓托管到 gitea:3000/ssw/dacli.git。 - 工作树为 ssw main dacli subpath 最新版 (110 commit, 08-12) - 历史未带 ssw main 整体历史(避免大仓污染) - 此为新仓基线 commit,未来以本仓历史为主
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)
|
|
})
|
|
}) |