mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

This commit refactors the callback in test/parallel/test-fs-read.js to use common.mustSucceed() instead of common.mustCall(). common.mustSucceed() is the preferred helper for standard error-first callbacks that are expected to succeed, as it provides an explicit check that the `err` argument is null. This improves the clarity and robustness of the test. PR-URL: https://github.com/nodejs/node/pull/59204 Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
18 lines
608 B
JavaScript
18 lines
608 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const filepath = fixtures.path('x.txt');
|
|
const fd = fs.openSync(filepath, 'r');
|
|
const bufferAsync = Buffer.alloc(0);
|
|
const bufferSync = Buffer.alloc(0);
|
|
|
|
fs.read(fd, bufferAsync, 0, 0, 0, common.mustSucceed((bytesRead) => {
|
|
assert.strictEqual(bytesRead, 0);
|
|
assert.deepStrictEqual(bufferAsync, Buffer.alloc(0));
|
|
}));
|
|
|
|
const r = fs.readSync(fd, bufferSync, 0, 0, 0);
|
|
assert.deepStrictEqual(bufferSync, Buffer.alloc(0));
|
|
assert.strictEqual(r, 0);
|