Skip to content

Commit 1ebb5b9

Browse files
davidmarkclementsFishrock123
davidmarkclements
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 <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent 8b7c97b commit 1ebb5b9

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

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

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var http = require('http');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const http = require('http');
55

6-
var server = http.createServer(function(req, res) {
6+
const server = 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
var req = 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)