Skip to content

Commit 816f609

Browse files
thefourtheyeFishrock123
authored andcommitted
test: use tmpDir instead of fixtures in readdir
This patch - makes the test use tmp directory instead of the fixtures directory, - simplifies the code - moves the test to `parallel`. PR-URL: #2587 Reviewed-By: Rich Trott <[email protected]>
1 parent bc9f629 commit 816f609

File tree

10 files changed

+36
-71
lines changed

10 files changed

+36
-71
lines changed

test/fixtures/readdir/are

Whitespace-only changes.

test/fixtures/readdir/dir/empty

Whitespace-only changes.

test/fixtures/readdir/empty

Whitespace-only changes.

test/fixtures/readdir/files

Whitespace-only changes.

test/fixtures/readdir/for

Whitespace-only changes.

test/fixtures/readdir/just

Whitespace-only changes.

test/fixtures/readdir/testing.js

Whitespace-only changes.

test/fixtures/readdir/these

Whitespace-only changes.

test/parallel/test-fs-readdir.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const path = require('path');
6+
const fs = require('fs');
7+
8+
const readdirDir = common.tmpDir;
9+
const files = ['empty', 'files', 'for', 'just', 'testing'];
10+
11+
// Make sure tmp directory is clean
12+
common.refreshTmpDir();
13+
14+
// Create the necessary files
15+
files.forEach(function(currentFile) {
16+
fs.closeSync(fs.openSync(readdirDir + '/' + currentFile, 'w'));
17+
});
18+
19+
// Check the readdir Sync version
20+
assert.deepEqual(files, fs.readdirSync(readdirDir).sort());
21+
22+
// Check the readdir async version
23+
fs.readdir(readdirDir, common.mustCall(function(err, f) {
24+
assert.ifError(err);
25+
assert.deepEqual(files, f.sort());
26+
}));
27+
28+
// readdir() on file should throw ENOTDIR
29+
// https://github.com/joyent/node/issues/1869
30+
assert.throws(function() {
31+
fs.readdirSync(__filename);
32+
}, /Error: ENOTDIR: not a directory/);
33+
34+
fs.readdir(__filename, common.mustCall(function(e) {
35+
assert.equal(e.code, 'ENOTDIR');
36+
}));

test/sequential/test-readdir.js

-71
This file was deleted.

0 commit comments

Comments
 (0)