import { tap, expect } from '@git.zone/tstest/tapbundle'; import { DapCli, MountManager, PortProxy, SshClient } from '../ts/index.js'; tap.test('should build ssh and proxy command args', async () => { const sshClient = new SshClient(); const sshArgs = sshClient.buildSshArgs('production', { localForwards: ['5433:127.0.0.1:5432'], reverseForwards: ['127.0.0.1:45000:127.0.0.1:3000'], remoteCommand: 'echo ok', }); expect(sshArgs).toEqual([ '-o', 'ExitOnForwardFailure=yes', '-L', '5433:127.0.0.1:5432', '-R', '127.0.0.1:45000:127.0.0.1:3000', 'production', 'echo ok', ]); const portProxy = new PortProxy(sshClient); expect(portProxy.buildArgs({ host: 'production', localForward: '8080:127.0.0.1:80' })).toEqual([ '-o', 'ExitOnForwardFailure=yes', '-L', '8080:127.0.0.1:80', '-N', 'production', ]); }); tap.test('should parse mount specs and cli flags', async () => { const mountManager = new MountManager(); expect(mountManager.parseRemoteSpec('production:/srv/app')).toEqual({ host: 'production', remotePath: '/srv/app', }); expect( mountManager.buildSshfsArgs({ host: 'production', remotePath: '/srv/app', localPath: './mount' }) ).toEqual(['production:/srv/app', './mount']); const cli = new DapCli(); expect(cli.parseArgs(['ssh', 'production', '--no-bridge', '--', '-A']).passthrough).toEqual(['-A']); expect(cli.parseArgs(['add', 'prod', '--hostname', 'example.com']).flags.hostname).toEqual('example.com'); }); export default tap.start();