Skip to content

Commit

Permalink
test: rename regression tests more expressively
Browse files Browse the repository at this point in the history
PR-URL: #19495
Refs: #19105
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
ryzokuken authored and targos committed Mar 27, 2018
1 parent 0310df8 commit 40be64d
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
'use strict';
require('../common');

// This test ensures Math functions don't fail with an "illegal instruction"
// error on ARM devices (primarily on the Raspberry Pi 1)
// See https://github.com/nodejs/node/issues/1376
// and https://code.google.com/p/v8/issues/detail?id=4019

require('../common');
Math.abs(-0.5);
Math.acos(-0.5);
Math.acosh(-0.5);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';

const common = require('../common');

// This test ensures that Node.js throws a RangeError when trying to convert a
// gigantic buffer into a string.
// Regression test for https://github.com/nodejs/node/issues/649.

const assert = require('assert');
const SlowBuffer = require('buffer').SlowBuffer;

// Regression test for https://github.com/nodejs/node/issues/649.
const len = 1422561062959;
const message = common.expectsError({
code: 'ERR_INVALID_OPT_VALUE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
// Remove this test once we support sending strings.

require('../common');

// This test ensures that a TypeError is raised when the argument to `send()`
// or `sendto()` is anything but a Buffer.
// https://github.com/nodejs/node-v0.x-archive/issues/4496

const assert = require('assert');
const dgram = require('dgram');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@

'use strict';
const common = require('../common');
const dns = require('dns');

// Should not raise assertion error.
// This test ensures `dns.resolveNs()` does not raise a C++-land assertion error
// and throw a JavaScript TypeError instead.
// Issue https://github.com/nodejs/node-v0.x-archive/issues/7070
common.expectsError(() => dns.resolveNs([]), // bad name
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "name" argument must be of type string/
});
common.expectsError(() => dns.resolveNs(''), // bad callback
{
code: 'ERR_INVALID_CALLBACK',
type: TypeError
});

const dns = require('dns');

common.expectsError(
() => dns.resolveNs([]), // bad name
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "name" argument must be of type string/
}
);
common.expectsError(
() => dns.resolveNs(''), // bad callback
{
code: 'ERR_INVALID_CALLBACK',
type: TypeError
}
);
41 changes: 0 additions & 41 deletions test/parallel/test-http-agent-maxsockets-regress-4050.js

This file was deleted.

56 changes: 56 additions & 0 deletions test/parallel/test-http-agent-maxsockets-respected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';
const common = require('../common');
const Countdown = require('../common/countdown');

// This test ensures that the `maxSockets` value for `http.Agent` is respected.
// https://github.com/nodejs/node/issues/4050

const assert = require('assert');
const http = require('http');

const MAX_SOCKETS = 2;

const agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: MAX_SOCKETS,
maxFreeSockets: 2
});

const server = http.createServer(
common.mustCall((req, res) => {
res.end('hello world');
}, 6)
);

const countdown = new Countdown(6, () => server.close());

function get(path, callback) {
return http.get(
{
host: 'localhost',
port: server.address().port,
agent: agent,
path: path
},
callback
);
}

server.listen(
0,
common.mustCall(() => {
for (let i = 0; i < 6; i++) {
const request = get('/1', common.mustCall());
request.on(
'response',
common.mustCall(() => {
request.abort();
const sockets = agent.sockets[Object.keys(agent.sockets)[0]];
assert(sockets.length <= MAX_SOCKETS);
countdown.dec();
})
);
}
})
);

0 comments on commit 40be64d

Please sign in to comment.