Skip to content

Commit

Permalink
test: refactor test-http-abort-before-end
Browse files Browse the repository at this point in the history
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: #18508
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig authored and gibfahn committed Apr 13, 2018
1 parent 9bce141 commit cbd698a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions test/parallel/test-http-abort-before-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,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();
});
}));

0 comments on commit cbd698a

Please sign in to comment.