Skip to content

Commit

Permalink
test: cover error case in os getCheckedFunction()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
cjihrig authored and targos committed Sep 3, 2018
1 parent 30b22a6 commit fbc189b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/parallel/test-os-checked-function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'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\)$/
});

0 comments on commit fbc189b

Please sign in to comment.