diff options
author | cjihrig <cjihrig@gmail.com> | 2018-08-20 09:10:06 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-08-20 11:33:02 -0400 |
commit | 8d05a1590aaeab07050e019ac892e1ebacac456d (patch) | |
tree | 9a3e79256fc58536181957ded2fb1dd926ac1716 /test/parallel/test-os-checked-function.js | |
parent | 5e420f95b19d1c860f0288a91bc7888b1eac577a (diff) | |
download | android-node-v8-8d05a1590aaeab07050e019ac892e1ebacac456d.tar.gz android-node-v8-8d05a1590aaeab07050e019ac892e1ebacac456d.tar.bz2 android-node-v8-8d05a1590aaeab07050e019ac892e1ebacac456d.zip |
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: 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>
Diffstat (limited to 'test/parallel/test-os-checked-function.js')
-rw-r--r-- | test/parallel/test-os-checked-function.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/parallel/test-os-checked-function.js b/test/parallel/test-os-checked-function.js new file mode 100644 index 0000000000..04c2c3a1f8 --- /dev/null +++ b/test/parallel/test-os-checked-function.js @@ -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\)$/ +}); |