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

Make tests more clear #8999

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions test/parallel/test-file-read-noexist.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
const common = require('../common');
const assert = require('assert');
const path = require('path');
const fs = require('fs');

var filename = path.join(common.fixturesDir, 'does_not_exist.txt');
const filename = path.join(common.fixturesDir, 'does_not_exist.txt');
fs.readFile(filename, 'latin1', common.mustCall(function(err, content) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we add a line after assert.ok(err) like assert.strictEqual(err.code, 'ENOENT') or whatever the right error code is? I assume it will be the same across platform, but correction welcome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

assert.ok(err);
assert.strictEqual(err.code, 'ENOENT');
}));
14 changes: 7 additions & 7 deletions test/parallel/test-file-write-stream2.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var path = require('path');
var fs = require('fs');
const path = require('path');
const fs = require('fs');


var filepath = path.join(common.tmpDir, 'write.txt');
const filepath = path.join(common.tmpDir, 'write.txt');
var file;

const EXPECTED = '012345678910';
Expand Down Expand Up @@ -76,12 +76,12 @@ file.on('close', function() {

file.on('error', function(err) {
cb_occurred += 'error ';
assert.ok(err.message.indexOf('write after end') >= 0);
assert.ok(err.message.includes('write after end'));
});


for (var i = 0; i < 11; i++) {
var ret = file.write(i + '');
const ret = file.write(i + '');
console.error('%d %j', i, ret);

// return false when i hits 10
Expand Down