-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
bc9f629
commit 816f609
Showing
10 changed files
with
36 additions
and
71 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
})); |
This file was deleted.
Oops, something went wrong.