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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
f0da38a5cb
commit
444b907e92
@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common');
|
const common = require('../common');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
var server = http.createServer(function(req, res) {
|
const server = http.createServer(function(req, res) {
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
'Content-Type': 'text/plain',
|
'Content-Type': 'text/plain',
|
||||||
'Connection': 'close'
|
'Connection': 'close'
|
||||||
@ -23,8 +23,8 @@ server.listen(common.PIPE, common.mustCall(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var req = http.get(options, common.mustCall(function(res) {
|
var req = http.get(options, common.mustCall(function(res) {
|
||||||
assert.equal(res.statusCode, 200);
|
assert.strictEqual(res.statusCode, 200);
|
||||||
assert.equal(res.headers['content-type'], 'text/plain');
|
assert.strictEqual(res.headers['content-type'], 'text/plain');
|
||||||
|
|
||||||
res.body = '';
|
res.body = '';
|
||||||
res.setEncoding('utf8');
|
res.setEncoding('utf8');
|
||||||
@ -34,19 +34,18 @@ server.listen(common.PIPE, common.mustCall(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.on('end', common.mustCall(function() {
|
res.on('end', common.mustCall(function() {
|
||||||
assert.equal(res.body, 'hello world\n');
|
assert.strictEqual(res.body, 'hello world\n');
|
||||||
server.close(function(error) {
|
server.close(common.mustCall(function(error) {
|
||||||
assert.equal(error, undefined);
|
assert.strictEqual(error, undefined);
|
||||||
server.close(function(error) {
|
server.close(common.mustCall(function(error) {
|
||||||
assert.equal(error && error.message, 'Not running');
|
assert.strictEqual(error && error.message, 'Not running');
|
||||||
});
|
}));
|
||||||
});
|
}));
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
req.on('error', function(e) {
|
req.on('error', function(e) {
|
||||||
console.log(e.stack);
|
common.fail(e.stack);
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
req.end();
|
req.end();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user