node/test/known_issues/test-fs-writeFileSync-invalid-windows.js
Rich Trott b6e301a9e0 test: add test-fs-writeFileSync-invalid-windows
Add a known_issues test for the Windows returning ENOTFOUND where EINVAL
is more appropriate. This happens with various functions in the `fs`
module when an invalid path is used.

Refs: https://github.com/nodejs/node/issues/8987

PR-URL: https://github.com/nodejs/node/pull/28569
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-07-11 10:27:42 -07:00

22 lines
585 B
JavaScript

'use strict';
const common = require('../common');
// Test that using an invalid file name with writeFileSync() on Windows returns
// EINVAL. With libuv 1.x, it returns ENOTFOUND. This should be fixed when we
// update to libuv 2.x.
//
// Refs: https://github.com/nodejs/node/issues/8987
const assert = require('assert');
const fs = require('fs');
if (!common.isWindows) {
// Change to `common.skip()` when the test is moved out of `known_issues`.
assert.fail('Windows-only test');
}
assert.throws(() => {
fs.writeFileSync('fhqwhgads??', 'come on');
}, { code: 'EINVAL' });