test: add common.mustNotCall()

This commit adds a mustNotCall() helper for testing. This provides
an alternative to using common.fail() as a callback, or creating
a callback function for the sole purpose of calling common.fail().

PR-URL: https://github.com/nodejs/node/pull/11152
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This commit is contained in:
cjihrig authored and Italo A. Casas committed 2017-02-14 11:52:23 -05:00
1 parent 44b17a21ad
commit f0eba7811d
124 files changed
+243 -234

No files matched your search

@@ -97,7 +97,7 @@ test(function serverResponseTimeout(cb) {
test(function serverRequestNotTimeoutAfterEnd(cb) {
function handler(req, res) {
// just do nothing, we should get a timeout event.
req.setTimeout(50, common.fail);
req.setTimeout(50, common.mustNotCall());
res.on('timeout', common.mustCall(function(socket) {}));
}
const server = https.createServer(serverOptions, common.mustCall(handler));
@@ -147,8 +147,8 @@ test(function serverResponseTimeoutWithPipeline(cb) {
test(function idleTimeout(cb) {
const server = https.createServer(serverOptions,
common.mustCall(function(req, res) {
req.on('timeout', common.fail);
res.on('timeout', common.fail);
req.on('timeout', common.mustNotCall());
res.on('timeout', common.mustNotCall());
res.end();
}));
server.setTimeout(50, common.mustCall(function(socket) {