Browse Source

test: add fs-assert-encoding's test

Check the error of `assertEncoding`.
Confirmed in every place being used.(a place where `getoptions` is used)
assetEncoding: 521767c886/lib/internal/fs.js (L18)

PR-URL: https://github.com/nodejs/node/pull/10913
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
v7.x
abouthiroppy 8 years ago
committed by Italo A. Casas
parent
commit
8ac6a709b9
No known key found for this signature in database GPG Key ID: 23EFEFE93C4CFFFE
  1. 76
      test/parallel/test-fs-assert-encoding-error.js

76
test/parallel/test-fs-assert-encoding-error.js

@ -0,0 +1,76 @@
'use strict';
require('../common');
const assert = require('assert');
const fs = require('fs');
const options = 'test';
const noop = () => {};
const unknownEncodingMessage = /^Error: Unknown encoding: test$/;
assert.throws(() => {
fs.readFile('path', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.readFileSync('path', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.readdir('path', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.readdirSync('path', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.readlink('path', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.readlinkSync('path', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.writeFile('path', 'data', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.writeFileSync('path', 'data', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.appendFile('path', 'data', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.appendFileSync('path', 'data', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.watch('path', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.realpath('path', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.realpathSync('path', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.mkdtemp('path', options, noop);
}, unknownEncodingMessage);
assert.throws(() => {
fs.mkdtempSync('path', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.ReadStream('path', options);
}, unknownEncodingMessage);
assert.throws(() => {
fs.WriteStream('path', options);
}, unknownEncodingMessage);
Loading…
Cancel
Save