Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve code in test-fs-open.js #10312

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions test/parallel/test-fs-open.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var fs = require('fs');
const assert = require('assert');
const fs = require('fs');

let caughtException = false;

var caughtException = false;
try {
// should throw ENOENT, not EBADF
// see https://github.com/joyent/node/pull/1228
fs.openSync('/path/to/file/that/does/not/exist', 'r');
} catch (e) {
assert.equal(e.code, 'ENOENT');
assert.strictEqual(e.code, 'ENOENT');
caughtException = true;
}
assert.ok(caughtException);
assert.strictEqual(caughtException, true);

fs.open(__filename, 'r', common.mustCall(function(err, fd) {
if (err) {
throw err;
}
fs.open(__filename, 'r', common.mustCall((err) => {
assert.ifError(err);
}));

fs.open(__filename, 'rs', common.mustCall(function(err, fd) {
if (err) {
throw err;
}
fs.open(__filename, 'rs', common.mustCall((err) => {
assert.ifError(err);
}));