Skip to content

Commit

Permalink
test: removed mustCallAsync from common and added inside testcase
Browse files Browse the repository at this point in the history
PR-URL: #23467
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
quinnlangille authored and MylesBorins committed Oct 30, 2018
1 parent 99d39f9 commit 87367ec
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
11 changes: 0 additions & 11 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,6 @@ fail.

If `fn` is not provided, an empty function will be used.

### mustCallAsync([fn][, exact])
* `fn` [&lt;Function>]
* `exact` [&lt;number>] default = 1
* return [&lt;Function>]

The same as `mustCall()`, except that it is also checked that the Promise
returned by the function is fulfilled for each invocation of the function.

The return value of the wrapped function is the return value of the original
function, if necessary wrapped as a promise.

### mustCallAtLeast([fn][, minimum])
* `fn` [&lt;Function>] default = () => {}
* `minimum` [&lt;number>] default = 1
Expand Down
7 changes: 0 additions & 7 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,6 @@ function mustCallAtLeast(fn, minimum) {
return _mustCallInner(fn, minimum, 'minimum');
}

function mustCallAsync(fn, exact) {
return mustCall((...args) => {
return Promise.resolve(fn(...args)).then(mustCall((val) => val));
}, exact);
}

function _mustCallInner(fn, criteria = 1, field) {
if (process._exiting)
throw new Error('Cannot use common.mustCall*() in process exit handler');
Expand Down Expand Up @@ -721,7 +715,6 @@ module.exports = {
isWindows,
localIPv6Hosts,
mustCall,
mustCallAsync,
mustCallAtLeast,
mustNotCall,
nodeProcessAborted,
Expand Down
2 changes: 0 additions & 2 deletions test/common/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const {
allowGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
hasMultiLocalhost,
skipIfEslintMissing,
canCreateSymLink,
Expand Down Expand Up @@ -74,7 +73,6 @@ export {
allowGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
hasMultiLocalhost,
skipIfEslintMissing,
canCreateSymLink,
Expand Down
8 changes: 7 additions & 1 deletion test/parallel/test-http2-backpressure.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const makeDuplexPair = require('../common/duplexpair');
{
let req;
const server = http2.createServer();
server.on('stream', common.mustCallAsync(async (stream, headers) => {
server.on('stream', mustCallAsync(async (stream, headers) => {
stream.respond({
'content-type': 'text/html',
':status': 200
Expand Down Expand Up @@ -45,3 +45,9 @@ function event(ee, eventName) {
ee.once(eventName, common.mustCall(resolve));
});
}

function mustCallAsync(fn, exact) {
return common.mustCall((...args) => {
return Promise.resolve(fn(...args)).then(common.mustCall((val) => val));
}, exact);
}

0 comments on commit 87367ec

Please sign in to comment.