Skip to content

Commit fbc189b

Browse files
cjihrigtargos
authored andcommitted
test: cover error case in os getCheckedFunction()
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: #22394 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 30b22a6 commit fbc189b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
// Monkey patch the os binding before requiring any other modules, including
3+
// common, which requires the os module.
4+
process.binding('os').getHomeDirectory = function(ctx) {
5+
ctx.syscall = 'foo';
6+
ctx.code = 'bar';
7+
ctx.message = 'baz';
8+
};
9+
10+
const common = require('../common');
11+
const os = require('os');
12+
13+
common.expectsError(os.homedir, {
14+
message: /^A system error occurred: foo returned bar \(baz\)$/
15+
});

0 commit comments

Comments
 (0)