Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: convert to mustSucceed
Convert statements of the form assert(!err) to mustSucceed.
  • Loading branch information
tniessen committed Oct 13, 2020
commit ea010608d5841ff029ff5434c3c8ed7552ed543e
8 changes: 4 additions & 4 deletions test/parallel/test-child-process-exec-any-shells-windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fs.mkdirSync(tmpPath);

const test = (shell) => {
cp.exec('echo foo bar', { shell: shell },
common.mustCall((error, stdout, stderror) => {
assert.ok(!error && !stderror);
common.mustSucceed((stdout, stderror) => {
assert.ok(!stderror);
assert.ok(stdout.includes('foo') && stdout.includes('bar'));
}));
};
Expand Down Expand Up @@ -46,8 +46,8 @@ testCopy('powershell.exe',
fs.writeFile(`${tmpPath}\\test file`, 'Test', common.mustSucceed(() => {
cp.exec(`Get-ChildItem "${tmpPath}" | Select-Object -Property Name`,
{ shell: 'PowerShell' },
common.mustCall((error, stdout, stderror) => {
assert.ok(!error && !stderror);
common.mustSucceed((stdout, stderror) => {
assert.ok(!stderror);
assert.ok(stdout.includes(
'test file'));
}));
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-fs-readfilesync-enoent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ function test(p) {
const result = fs.realpathSync(p);
assert.strictEqual(result.toLowerCase(), path.resolve(p).toLowerCase());

fs.realpath(p, common.mustCall(function(err, result) {
assert.ok(!err);
fs.realpath(p, common.mustSucceed(function(result) {
assert.strictEqual(result.toLowerCase(), path.resolve(p).toLowerCase());
}));
}
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-fs-truncate-fd.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const msg = 'Using fs.truncate with a file descriptor is deprecated.' +


common.expectWarning('DeprecationWarning', msg, 'DEP0081');
fs.truncate(fd, 5, common.mustCall((err) => {
assert.ok(!err);
fs.truncate(fd, 5, common.mustSucceed(() => {
assert.strictEqual(fs.readFileSync(filename, 'utf8'), 'hello');
}));

Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-quic-quicsocket-packetloss-stream-rx.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ const countdown = new Countdown(1, () => {
debug('QuicServerSession Created');
session.on('stream', common.mustCall((stream) => {
debug('Bidirectional, Client-initiated stream %d received', stream.id);
pipeline(stream, stream, common.mustCall((err) => {
assert(!err);
}));
pipeline(stream, stream, common.mustSucceed());
}));
}));

Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-quic-quicsocket-packetloss-stream-tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ const countdown = new Countdown(1, () => {
debug('QuicServerSession Created');
session.on('stream', common.mustCall((stream) => {
debug('Bidirectional, Client-initiated stream %d received', stream.id);
pipeline(stream, stream, common.mustCall((err) => {
assert(!err);
}));
pipeline(stream, stream, common.mustSucceed());
}));
}));

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-quic-quicstream-close-early.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const countdown = new Countdown(2, () => {
server.on('session', common.mustCall(async (session) => {
if (qlog) session.qlog.pipe(createWriteStream('server.qlog'));
const uni = await session.openStream({ halfOpen: true });
uni.write('hi', common.mustCall((err) => assert(!err)));
uni.write('hi', common.mustSucceed());
uni.on('error', common.mustNotCall());
uni.on('data', common.mustNotCall());
uni.on('close', common.mustCall());
Expand Down Expand Up @@ -67,8 +67,8 @@ const countdown = new Countdown(2, () => {
}));

const stream = await req.openStream();
stream.write('hello', common.mustCall((err) => assert(!err)));
stream.write('there', common.mustCall((err) => assert(!err)));
stream.write('hello', common.mustSucceed());
stream.write('there', common.mustSucceed());
stream.resume();
stream.on('error', common.mustNotCall());
stream.on('end', common.mustCall());
Expand Down
15 changes: 4 additions & 11 deletions test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ const http = require('http');
read() {}
});

finished(rs, common.mustCall((err) => {
assert(!err, 'no error');
}));
finished(rs, common.mustSucceed());

rs.push(null);
rs.resume();
Expand All @@ -35,9 +33,7 @@ const http = require('http');
}
});

finished(ws, common.mustCall((err) => {
assert(!err, 'no error');
}));
finished(ws, common.mustSucceed());

ws.end();
}
Expand All @@ -60,8 +56,7 @@ const http = require('http');
finish = true;
});

finished(tr, common.mustCall((err) => {
assert(!err, 'no error');
finished(tr, common.mustSucceed(() => {
assert(finish);
assert(ended);
}));
Expand Down Expand Up @@ -108,9 +103,7 @@ const http = require('http');
{
const rs = new Readable();

finished(rs, common.mustCall((err) => {
assert(!err, 'no error');
}));
finished(rs, common.mustSucceed());

rs.push(null);
rs.emit('close'); // Should not trigger an error
Expand Down
39 changes: 13 additions & 26 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const net = require('net');
}
read.push(null);

pipeline(read, write, common.mustCall((err) => {
assert.ok(!err, 'no error');
pipeline(read, write, common.mustSucceed(() => {
assert.ok(finished);
assert.deepStrictEqual(processed, expected);
}));
Expand Down Expand Up @@ -376,8 +375,7 @@ const net = require('net');
rs,
oldStream,
ws,
common.mustCall((err) => {
assert(!err, 'no error');
common.mustSucceed(() => {
assert(finished, 'last stream finished');
})
);
Expand Down Expand Up @@ -528,8 +526,7 @@ const net = require('net');
pipeline(function*() {
yield 'hello';
yield 'world';
}(), w, common.mustCall((err) => {
assert.ok(!err);
}(), w, common.mustSucceed(() => {
assert.strictEqual(res, 'helloworld');
}));
}
Expand All @@ -546,8 +543,7 @@ const net = require('net');
await Promise.resolve();
yield 'hello';
yield 'world';
}(), w, common.mustCall((err) => {
assert.ok(!err);
}(), w, common.mustSucceed(() => {
assert.strictEqual(res, 'helloworld');
}));
}
Expand All @@ -563,8 +559,7 @@ const net = require('net');
pipeline(function*() {
yield 'hello';
yield 'world';
}, w, common.mustCall((err) => {
assert.ok(!err);
}, w, common.mustSucceed(() => {
assert.strictEqual(res, 'helloworld');
}));
}
Expand All @@ -581,8 +576,7 @@ const net = require('net');
await Promise.resolve();
yield 'hello';
yield 'world';
}, w, common.mustCall((err) => {
assert.ok(!err);
}, w, common.mustSucceed(() => {
assert.strictEqual(res, 'helloworld');
}));
}
Expand All @@ -601,8 +595,7 @@ const net = require('net');
for await (const chunk of source) {
res += chunk;
}
}, common.mustCall((err) => {
assert.ok(!err);
}, common.mustSucceed(() => {
assert.strictEqual(res, 'HELLOWORLD');
}));
}
Expand All @@ -622,8 +615,7 @@ const net = require('net');
ret += chunk;
}
return ret;
}, common.mustCall((err, val) => {
assert.ok(!err);
}, common.mustSucceed((val) => {
assert.strictEqual(val, 'HELLOWORLD');
}));
}
Expand Down Expand Up @@ -895,8 +887,7 @@ const net = require('net');
for await (const chunk of source) {
res += chunk;
}
}, common.mustCall((err) => {
assert.ok(!err);
}, common.mustSucceed(() => {
assert.strictEqual(res, 'HELLOWORLD');
}));
}
Expand Down Expand Up @@ -954,8 +945,7 @@ const net = require('net');
pipeline(
body,
req,
common.mustCall((err) => {
assert(!err);
common.mustSucceed(() => {
assert(!req.res);
assert(!req.aborted);
req.abort();
Expand All @@ -969,8 +959,7 @@ const net = require('net');
{
const src = new PassThrough();
const dst = new PassThrough();
pipeline(src, dst, common.mustCall((err) => {
assert(!err);
pipeline(src, dst, common.mustSucceed(() => {
assert.strictEqual(dst.destroyed, false);
}));
src.end();
Expand All @@ -980,8 +969,7 @@ const net = require('net');
const src = new PassThrough();
const dst = new PassThrough();
dst.readable = false;
pipeline(src, dst, common.mustCall((err) => {
assert(!err);
pipeline(src, dst, common.mustSucceed(() => {
assert.strictEqual(dst.destroyed, false);
}));
src.end();
Expand Down Expand Up @@ -1224,8 +1212,7 @@ const net = require('net');
callback();
}
});
pipeline([r, w], common.mustCall((err) => {
assert.ok(!err);
pipeline([r, w], common.mustSucceed(() => {
assert.strictEqual(res, 'helloworld');
}));
}
Expand Down