Skip to content

Commit

Permalink
test: use mustSucceed instead of mustCall with assert.ifError
Browse files Browse the repository at this point in the history
PR-URL: #44196
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
fossamagna authored and juanarbol committed Oct 11, 2022
1 parent 1cc050e commit 8725a87
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test/sequential/test-inspector-open.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,23 @@ let firstPort;
function firstOpen(msg) {
assert.strictEqual(msg.cmd, 'url');
const port = url.parse(msg.url).port;
ping(port, (err) => {
assert.ifError(err);
ping(port, common.mustSucceed(() => {
// Inspector is already open, and won't be reopened, so args don't matter.
child.send({ cmd: 'open', args: [kOpenWhileOpen] });
child.once('message', common.mustCall(tryToOpenWhenOpen));
firstPort = port;
});
}));
}

function tryToOpenWhenOpen(msg) {
assert.strictEqual(msg.cmd, 'url');
const port = url.parse(msg.url).port;
// Reopen didn't do anything, the port was already open, and has not changed.
assert.strictEqual(port, firstPort);
ping(port, (err) => {
assert.ifError(err);
ping(port, common.mustSucceed(() => {
child.send({ cmd: 'close' });
child.once('message', common.mustCall(closeWhenOpen));
});
}));
}

function closeWhenOpen(msg) {
Expand All @@ -73,10 +71,9 @@ function tryToCloseWhenClosed(msg) {
function reopenAfterClose(msg) {
assert.strictEqual(msg.cmd, 'url');
const port = url.parse(msg.url).port;
ping(port, (err) => {
assert.ifError(err);
ping(port, common.mustSucceed(() => {
process.exit();
});
}));
}

function ping(port, callback) {
Expand Down

0 comments on commit 8725a87

Please sign in to comment.