From 50e701defb6e8bc889ecc84ee4dd6929b781741a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 9 Apr 2022 16:25:18 +0200 Subject: [PATCH] test: simplify test-http-write-callbacks.js PR-URL: https://github.com/nodejs/node/pull/42628 Reviewed-By: Darshan Sen Reviewed-By: Antoine du Hamel --- test/parallel/test-http-write-callbacks.js | 31 +++++++++------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-http-write-callbacks.js b/test/parallel/test-http-write-callbacks.js index 3730e57936b4a6..390fddf1dc2911 100644 --- a/test/parallel/test-http-write-callbacks.js +++ b/test/parallel/test-http-write-callbacks.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const http = require('http'); @@ -53,15 +53,13 @@ server.on('checkContinue', (req, res) => { res.writeContinue(() => { // Continue has been written req.on('end', () => { - res.write('asdf', (er) => { - assert.ifError(er); - res.write('foo', 'ascii', (er) => { - assert.ifError(er); - res.end(Buffer.from('bar'), 'buffer', (er) => { + res.write('asdf', common.mustSucceed(() => { + res.write('foo', 'ascii', common.mustSucceed(() => { + res.end(Buffer.from('bar'), 'buffer', common.mustSucceed(() => { serverEndCb = true; - }); - }); - }); + })); + })); + })); }); }); @@ -79,16 +77,13 @@ server.listen(0, function() { }); req.on('continue', () => { // ok, good to go. - req.write('YmF6', 'base64', (er) => { - assert.ifError(er); - req.write(Buffer.from('quux'), (er) => { - assert.ifError(er); - req.end('626c657267', 'hex', (er) => { - assert.ifError(er); + req.write('YmF6', 'base64', common.mustSucceed(() => { + req.write(Buffer.from('quux'), common.mustSucceed(() => { + req.end('626c657267', 'hex', common.mustSucceed(() => { clientEndCb = true; - }); - }); - }); + })); + })); + })); }); req.on('response', (res) => { // This should not come until after the end is flushed out