test: refactor test-http-abort-before-end

This test was added over six years ago, and the behavior
seems to have changed since then. When the test was originally
written, common.mustCall() did not exist. The only assertion
in this test was not actually executing. Instead of an 'error'
event being emitted as expected, an 'abort' event was emitted.

PR-URL: https://github.com/nodejs/node/pull/18508
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
cjihrig authored and Gibson Fahnestock committed 2018-04-13 03:52:33 +01:00
1 parent 44ab85018c
commit bc883fb136
1 file changed
+8 -11
+8 -11
View File
@@ -1,25 +1,22 @@
'use strict';
const common = require('../common');
const http = require('http');
const assert = require('assert');
const server = http.createServer(common.mustNotCall());
server.listen(0, function() {
server.listen(0, common.mustCall(() => {
const req = http.request({
method: 'GET',
host: '127.0.0.1',
port: this.address().port
port: server.address().port
});
req.on('error', function(ex) {
// https://github.com/joyent/node/issues/1399#issuecomment-2597359
// abort() should emit an Error, not the net.Socket object
assert(ex instanceof Error);
});
req.on('abort', common.mustCall(() => {
server.close();
}));
req.on('error', common.mustNotCall());
req.abort();
req.end();
server.close();
});
}));