mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 17:57:53 +00:00

getCheckedFunction() is used internally by the os module to handle errors from the binding layer in several methods. This commit adds a test for the case where the binding layer returns an error. PR-URL: https://github.com/nodejs/node/pull/22394 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
16 lines
426 B
JavaScript
16 lines
426 B
JavaScript
'use strict';
|
|
// Monkey patch the os binding before requiring any other modules, including
|
|
// common, which requires the os module.
|
|
process.binding('os').getHomeDirectory = function(ctx) {
|
|
ctx.syscall = 'foo';
|
|
ctx.code = 'bar';
|
|
ctx.message = 'baz';
|
|
};
|
|
|
|
const common = require('../common');
|
|
const os = require('os');
|
|
|
|
common.expectsError(os.homedir, {
|
|
message: /^A system error occurred: foo returned bar \(baz\)$/
|
|
});
|