Skip to content

Commit 8e5dad3

Browse files
committed
test: expand VFS provider and promises test coverage
- Expand test-vfs-provider-memory.js with comprehensive tests: - Provider instantiation and VFS creation - File operations (read, write, append, copy, rename, unlink) - Directory operations (mkdir, rmdir, readdir, recursive mkdir) - Stat/lstat operations with error handling - Symlink operations (symlink, readlink, lstat) - File handle operations (sync and async) - Mounting tests - Readonly mode tests (sync and async) - Add promises.symlink and promises.readlink tests to test-vfs-promises.js for complete promises API coverage
1 parent 7a18822 commit 8e5dad3

File tree

2 files changed

+586
-0
lines changed

2 files changed

+586
-0
lines changed

test/parallel/test-vfs-promises.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,32 @@ const vfs = require('node:vfs');
375375
);
376376
})().then(common.mustCall());
377377

378+
// Test promises.symlink and promises.readlink
379+
(async () => {
380+
const myVfs = vfs.create();
381+
myVfs.writeFileSync('/symlink-target.txt', 'symlink content');
382+
383+
await myVfs.promises.symlink('/symlink-target.txt', '/symlink-link.txt');
384+
385+
// Verify symlink was created
386+
const lstat = myVfs.lstatSync('/symlink-link.txt');
387+
assert.strictEqual(lstat.isSymbolicLink(), true);
388+
389+
// Read through symlink
390+
const content = await myVfs.promises.readFile('/symlink-link.txt', 'utf8');
391+
assert.strictEqual(content, 'symlink content');
392+
393+
// Readlink should return target
394+
const target = await myVfs.promises.readlink('/symlink-link.txt');
395+
assert.strictEqual(target, '/symlink-target.txt');
396+
397+
// Readlink on non-symlink should error
398+
await assert.rejects(
399+
myVfs.promises.readlink('/symlink-target.txt'),
400+
{ code: 'EINVAL' }
401+
);
402+
})().then(common.mustCall());
403+
378404
// Test async truncate (via file handle)
379405
(async () => {
380406
const myVfs = vfs.create();

0 commit comments

Comments
 (0)