Skip to content

Commit 342a3c9

Browse files
davidmarkclementsMylesBorins
authored andcommitted
test: refactor test-http-unix-socket
Use `common.mustCall()` and `common.fail()` where appropriate. Change `assert.equal` to `assert.strictEqual` to ensure specificity. Change var declarations to const to take advantage of ES6 immutable bindings. PR-URL: #10072 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent ecca81f commit 342a3c9

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

‎test/parallel/test-http-unix-socket.js‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
4-
varhttp=require('http');
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
consthttp=require('http');
55

6-
varserver=http.createServer(function(req,res){
6+
constserver=http.createServer(function(req,res){
77
res.writeHead(200,{
88
'Content-Type': 'text/plain',
99
'Connection': 'close'
@@ -23,8 +23,8 @@ server.listen(common.PIPE, common.mustCall(function() {
2323
};
2424

2525
varreq=http.get(options,common.mustCall(function(res){
26-
assert.equal(res.statusCode,200);
27-
assert.equal(res.headers['content-type'],'text/plain');
26+
assert.strictEqual(res.statusCode,200);
27+
assert.strictEqual(res.headers['content-type'],'text/plain');
2828

2929
res.body='';
3030
res.setEncoding('utf8');
@@ -34,19 +34,18 @@ server.listen(common.PIPE, common.mustCall(function() {
3434
});
3535

3636
res.on('end',common.mustCall(function(){
37-
assert.equal(res.body,'hello world\n');
38-
server.close(function(error){
39-
assert.equal(error,undefined);
40-
server.close(function(error){
41-
assert.equal(error&&error.message,'Not running');
42-
});
43-
});
37+
assert.strictEqual(res.body,'hello world\n');
38+
server.close(common.mustCall(function(error){
39+
assert.strictEqual(error,undefined);
40+
server.close(common.mustCall(function(error){
41+
assert.strictEqual(error&&error.message,'Not running');
42+
}));
43+
}));
4444
}));
4545
}));
4646

4747
req.on('error',function(e){
48-
console.log(e.stack);
49-
process.exit(1);
48+
common.fail(e.stack);
5049
});
5150

5251
req.end();

0 commit comments

Comments
 (0)