49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import {
|
|
downloadRemoteFile,
|
|
localPath,
|
|
readRemoteTextFile,
|
|
remotePath,
|
|
uploadRemoteFile,
|
|
writeRemoteTextFile,
|
|
} from '../../src/platform/sftp'
|
|
|
|
describe('SFTP path semantics', () => {
|
|
beforeEach(() => vi.clearAllMocks())
|
|
|
|
it('always sends local then remote paths for upload', async () => {
|
|
await uploadRemoteFile({
|
|
sftpId: 'sftp-1',
|
|
localPath: localPath('/Users/me/app.log'),
|
|
remotePath: remotePath('/var/log/app.log'),
|
|
})
|
|
|
|
expect(window.opsxApi.sftpUpload).toHaveBeenCalledWith('sftp-1', '/Users/me/app.log', '/var/log/app.log')
|
|
})
|
|
|
|
it('always sends remote then local paths for download', async () => {
|
|
await downloadRemoteFile({
|
|
sftpId: 'sftp-1',
|
|
remotePath: remotePath('/var/log/app.log'),
|
|
localPath: localPath('/Users/me/app.log'),
|
|
})
|
|
|
|
expect(window.opsxApi.sftpDownload).toHaveBeenCalledWith('sftp-1', '/var/log/app.log', '/Users/me/app.log')
|
|
})
|
|
|
|
it('keeps remote editor reads and writes separate from transfers', async () => {
|
|
await readRemoteTextFile({ sftpId: 'sftp-1', remotePath: remotePath('/etc/hosts') })
|
|
await writeRemoteTextFile({
|
|
sftpId: 'sftp-1',
|
|
remotePath: remotePath('/etc/hosts'),
|
|
content: '127.0.0.1 localhost',
|
|
})
|
|
|
|
expect(window.opsxApi.sftpReadText).toHaveBeenCalledWith('sftp-1', '/etc/hosts')
|
|
expect(window.opsxApi.sftpWriteText).toHaveBeenCalledWith('sftp-1', '/etc/hosts', '127.0.0.1 localhost')
|
|
expect(window.opsxApi.sftpUpload).not.toHaveBeenCalled()
|
|
expect(window.opsxApi.sftpDownload).not.toHaveBeenCalled()
|
|
})
|
|
})
|