Skip to content

Commit 2b5e531

Browse files
addaleaxitaloacasas
authored andcommitted
test: check error and cleanups in test-fs-read-buffer
Use arrow functions and prefer `strictEqual` over `deepStrictEqual` where it works. PR-URL: nodejs#10611 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 649af4c commit 2b5e531

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

test/parallel/test-fs-read-buffer.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function test(bufferAsync, bufferSync, expected) {
1616
expected.length,
1717
0,
1818
common.mustCall((err, bytesRead) => {
19+
assert.ifError(err);
1920
assert.strictEqual(bytesRead, expected.length);
2021
assert.deepStrictEqual(bufferAsync, Buffer.from(expected));
2122
}));

test/parallel/test-fs-write-buffer.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ common.refreshTmpDir();
1010
// fs.write with all parameters provided:
1111
{
1212
const filename = path.join(common.tmpDir, 'write1.txt');
13-
fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) {
13+
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
1414
assert.ifError(err);
1515

16-
const cb = common.mustCall(function(err, written) {
16+
const cb = common.mustCall((err, written) => {
1717
assert.ifError(err);
1818

1919
assert.strictEqual(expected.length, written);
2020
fs.closeSync(fd);
2121

2222
var found = fs.readFileSync(filename, 'utf8');
23-
assert.deepStrictEqual(expected.toString(), found);
23+
assert.strictEqual(expected.toString(), found);
2424
});
2525

2626
fs.write(fd, expected, 0, expected.length, null, cb);
@@ -30,17 +30,17 @@ common.refreshTmpDir();
3030
// fs.write with a buffer, without the length parameter:
3131
{
3232
const filename = path.join(common.tmpDir, 'write2.txt');
33-
fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) {
33+
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
3434
assert.ifError(err);
3535

36-
const cb = common.mustCall(function(err, written) {
36+
const cb = common.mustCall((err, written) => {
3737
assert.ifError(err);
3838

3939
assert.strictEqual(2, written);
4040
fs.closeSync(fd);
4141

4242
const found = fs.readFileSync(filename, 'utf8');
43-
assert.deepStrictEqual('lo', found);
43+
assert.strictEqual('lo', found);
4444
});
4545

4646
fs.write(fd, Buffer.from('hello'), 3, cb);
@@ -90,17 +90,17 @@ common.refreshTmpDir();
9090
// fs.write with offset and length passed as undefined followed by the callback:
9191
{
9292
const filename = path.join(common.tmpDir, 'write5.txt');
93-
fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) {
93+
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
9494
assert.ifError(err);
9595

96-
const cb = common.mustCall(function(err, written) {
96+
const cb = common.mustCall((err, written) => {
9797
assert.ifError(err);
9898

9999
assert.strictEqual(expected.length, written);
100100
fs.closeSync(fd);
101101

102102
const found = fs.readFileSync(filename, 'utf8');
103-
assert.deepStrictEqual(expected.toString(), found);
103+
assert.strictEqual(expected.toString(), found);
104104
});
105105

106106
fs.write(fd, expected, undefined, undefined, cb);
@@ -110,17 +110,17 @@ common.refreshTmpDir();
110110
// fs.write with a Uint8Array, without the offset and length parameters:
111111
{
112112
const filename = path.join(common.tmpDir, 'write6.txt');
113-
fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) {
113+
fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => {
114114
assert.ifError(err);
115115

116-
const cb = common.mustCall(function(err, written) {
116+
const cb = common.mustCall((err, written) => {
117117
assert.ifError(err);
118118

119119
assert.strictEqual(expected.length, written);
120120
fs.closeSync(fd);
121121

122122
const found = fs.readFileSync(filename, 'utf8');
123-
assert.deepStrictEqual(expected.toString(), found);
123+
assert.strictEqual(expected.toString(), found);
124124
});
125125

126126
fs.write(fd, Uint8Array.from(expected), cb);

0 commit comments

Comments
 (0)