/** * 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) }) })