Skip to content

Commit cbd698a

Browse files
cjihriggibfahn
authored andcommitted
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: #18508 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9bce141 commit cbd698a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/parallel/test-http-abort-before-end.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,22 @@
2222
'use strict';
2323
const common = require('../common');
2424
const http = require('http');
25-
const assert = require('assert');
2625

2726
const server = http.createServer(common.mustNotCall());
2827

29-
server.listen(0, function() {
28+
server.listen(0, common.mustCall(() => {
3029
const req = http.request({
3130
method: 'GET',
3231
host: '127.0.0.1',
33-
port: this.address().port
32+
port: server.address().port
3433
});
3534

36-
req.on('error', function(ex) {
37-
// https://github.com/joyent/node/issues/1399#issuecomment-2597359
38-
// abort() should emit an Error, not the net.Socket object
39-
assert(ex instanceof Error);
40-
});
35+
req.on('abort', common.mustCall(() => {
36+
server.close();
37+
}));
38+
39+
req.on('error', common.mustNotCall());
4140

4241
req.abort();
4342
req.end();
44-
45-
server.close();
46-
});
43+
}));

0 commit comments

Comments
 (0)