Initial curated chimera source from a8ae5b1db07fb49926c94585e2718e5130330974

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:38:08 +02:00
commit c737a37f71
531 files changed
+119270

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
'use strict';
const assert = require('node:assert/strict');
const test = require('node:test');
const { listDirectoryWithCwd } = require('../../src/ftp');
test('FTP directory listing uses an exact CWD and restores the prior directory', async () => {
const calls = [];
const client = {
pwd: async () => '/previous',
cd: async directory => { calls.push(['cd', directory]); },
list: async () => { calls.push(['list']); return [{ name: 'app0' }]; },
};
const result = await listDirectoryWithCwd(client, '/mnt/sandbox/PPSA17330_000');
assert.deepEqual(result, [{ name: 'app0' }]);
assert.deepEqual(calls, [
['cd', '/mnt/sandbox/PPSA17330_000'],
['list'],
['cd', '/previous'],
]);
});
test('FTP directory listing restores the prior directory after LIST failure', async () => {
const calls = [];
const client = {
pwd: async () => '/previous',
cd: async directory => { calls.push(['cd', directory]); },
list: async () => { calls.push(['list']); throw new Error('LIST rejected'); },
};
await assert.rejects(() => listDirectoryWithCwd(client, '/mnt/sandbox'), /LIST rejected/);
assert.deepEqual(calls.at(-1), ['cd', '/previous']);
});