Skip to content

Commit

Permalink
test: use tmpDir instead of fixtures in readdir
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
thefourtheye authored and Fishrock123 committed Sep 20, 2015
1 parent bc9f629 commit 816f609
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 71 deletions.
Empty file removed test/fixtures/readdir/are
Empty file.
Empty file removed test/fixtures/readdir/dir/empty
Empty file.
Empty file removed test/fixtures/readdir/empty
Empty file.
Empty file removed test/fixtures/readdir/files
Empty file.
Empty file removed test/fixtures/readdir/for
Empty file.
Empty file removed test/fixtures/readdir/just
Empty file.
Empty file removed test/fixtures/readdir/testing.js
Empty file.
Empty file removed test/fixtures/readdir/these
Empty file.
36 changes: 36 additions & 0 deletions test/parallel/test-fs-readdir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const path = require('path');
const fs = require('fs');

const readdirDir = common.tmpDir;
const files = ['empty', 'files', 'for', 'just', 'testing'];

// Make sure tmp directory is clean
common.refreshTmpDir();

// Create the necessary files
files.forEach(function(currentFile) {
fs.closeSync(fs.openSync(readdirDir + '/' + currentFile, 'w'));
});

// Check the readdir Sync version
assert.deepEqual(files, fs.readdirSync(readdirDir).sort());

// Check the readdir async version
fs.readdir(readdirDir, common.mustCall(function(err, f) {
assert.ifError(err);
assert.deepEqual(files, f.sort());
}));

// readdir() on file should throw ENOTDIR
// https://github.com/joyent/node/issues/1869
assert.throws(function() {
fs.readdirSync(__filename);
}, /Error: ENOTDIR: not a directory/);

fs.readdir(__filename, common.mustCall(function(e) {
assert.equal(e.code, 'ENOTDIR');
}));
71 changes: 0 additions & 71 deletions test/sequential/test-readdir.js

This file was deleted.

0 comments on commit 816f609

Please sign in to comment.