Skip to content

Commit bc883fb

Browse files
cjihriggibfahn
authored andcommittedApr 13, 2018
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 44ab850 commit bc883fb

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed
 
+8-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
'use strict';
22
const common = require('../common');
33
const http = require('http');
4-
const assert = require('assert');
54

65
const server = http.createServer(common.mustNotCall());
76

8-
server.listen(0, function() {
7+
server.listen(0, common.mustCall(() => {
98
const req = http.request({
109
method: 'GET',
1110
host: '127.0.0.1',
12-
port: this.address().port
11+
port: server.address().port
1312
});
1413

15-
req.on('error', function(ex) {
16-
// https://github.com/joyent/node/issues/1399#issuecomment-2597359
17-
// abort() should emit an Error, not the net.Socket object
18-
assert(ex instanceof Error);
19-
});
14+
req.on('abort', common.mustCall(() => {
15+
server.close();
16+
}));
17+
18+
req.on('error', common.mustNotCall());
2019

2120
req.abort();
2221
req.end();
23-
24-
server.close();
25-
});
22+
}));

0 commit comments

Comments
 (0)
Please sign in to comment.