diff --git a/test/parallel/test-pipe-file-to-http.js b/test/parallel/test-pipe-file-to-http.js index 8d804f70b7b0e1..f72cfe7d793348 100644 --- a/test/parallel/test-pipe-file-to-http.js +++ b/test/parallel/test-pipe-file-to-http.js @@ -1,20 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var http = require('http'); -var path = require('path'); -var cp = require('child_process'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const http = require('http'); +const path = require('path'); +const cp = require('child_process'); common.refreshTmpDir(); -var filename = path.join(common.tmpDir || '/tmp', 'big'); -var clientReqComplete = false; -var count = 0; +const filename = path.join(common.tmpDir || '/tmp', 'big'); +let count = 0; -var server = http.createServer(function(req, res) { - var timeoutId; - assert.equal('POST', req.method); +const server = http.createServer(function(req, res) { + let timeoutId; + assert.strictEqual('POST', req.method); req.pause(); setTimeout(function() { @@ -36,27 +35,26 @@ var server = http.createServer(function(req, res) { server.listen(0); server.on('listening', function() { - var cmd = common.ddCommand(filename, 10240); + const cmd = common.ddCommand(filename, 10240); - cp.exec(cmd, function(err, stdout, stderr) { + cp.exec(cmd, function(err) { if (err) throw err; makeRequest(); }); }); function makeRequest() { - var req = http.request({ + const req = http.request({ port: server.address().port, path: '/', method: 'POST' }); - var s = fs.ReadStream(filename); + const s = fs.ReadStream(filename); s.pipe(req); - s.on('close', function(err) { - if (err) throw err; - clientReqComplete = true; - }); + s.on('close', common.mustCall((err) => { + assert.ifError(err); + })); req.on('response', function(res) { res.resume(); @@ -67,6 +65,5 @@ function makeRequest() { } process.on('exit', function() { - assert.equal(1024 * 10240, count); - assert.ok(clientReqComplete); + assert.strictEqual(1024 * 10240, count); });