Skip to content

Commit ab1d435

Browse files
committed
vfs: remove unused entries.js, add error tests
- Remove lib/internal/vfs/entries.js which was dead code (not imported anywhere in the codebase) - Add tests for ENOTEMPTY error (rmdir on non-empty directory) - Add tests for EEXIST error (mkdir on existing directory) PR-URL: #61478
1 parent dae621c commit ab1d435

File tree

2 files changed

+30
-351
lines changed

2 files changed

+30
-351
lines changed

lib/internal/vfs/entries.js

Lines changed: 0 additions & 351 deletions
This file was deleted.

test/parallel/test-vfs-basic.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,33 @@ const vfs = require('node:vfs');
157157
myVfs.realpathSync('/nonexistent');
158158
}, { code: 'ENOENT' });
159159
}
160+
161+
// Test rmdir on non-empty directory throws ENOTEMPTY
162+
{
163+
const myVfs = vfs.create();
164+
myVfs.mkdirSync('/parent', { recursive: true });
165+
myVfs.writeFileSync('/parent/file.txt', 'content');
166+
167+
assert.throws(() => {
168+
myVfs.rmdirSync('/parent');
169+
}, { code: 'ENOTEMPTY' });
170+
171+
// After removing the file, rmdir should succeed
172+
myVfs.unlinkSync('/parent/file.txt');
173+
myVfs.rmdirSync('/parent');
174+
assert.strictEqual(myVfs.existsSync('/parent'), false);
175+
}
176+
177+
// Test mkdir on existing directory throws EEXIST (without recursive)
178+
{
179+
const myVfs = vfs.create();
180+
myVfs.mkdirSync('/existing', { recursive: true });
181+
182+
assert.throws(() => {
183+
myVfs.mkdirSync('/existing');
184+
}, { code: 'EEXIST' });
185+
186+
// With recursive: true, it should not throw
187+
myVfs.mkdirSync('/existing', { recursive: true });
188+
assert.strictEqual(myVfs.existsSync('/existing'), true);
189+
}

0 commit comments

Comments
 (0)