MCPcopy Index your code
hub / github.com/nodejs/node / validateReadFile

Function validateReadFile

test/parallel/test-fs-promises-file-handle-readFile.js:23–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21tmpdir.refresh();
22
23async function validateReadFile() {
24 const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
25 await using fileHandle = await open(filePath, 'w+');
26 const buffer = Buffer.from('Hello world'.repeat(100), 'utf8');
27
28 const fd = fs.openSync(filePath, 'w+');
29 fs.writeSync(fd, buffer, 0, buffer.length);
30 fs.closeSync(fd);
31
32 const readFileData = await fileHandle.readFile();
33 assert.deepStrictEqual(buffer, readFileData);
34}
35
36async function validateReadFileProc() {
37 // Test to make sure reading a file under the /proc directory works. Adapted

Calls 7

openFunction · 0.70
resolveMethod · 0.45
fromMethod · 0.45
openSyncMethod · 0.45
writeSyncMethod · 0.45
closeSyncMethod · 0.45
readFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…