Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Commit

Permalink
Add test for too-early callback when existing files are clobbered
Browse files Browse the repository at this point in the history
See AvianFlu#71 and related issues.
  • Loading branch information
maxg committed May 21, 2015
1 parent 7c970fb commit 3c88d8a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/ncp.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ describe('ncp', function () {
});
});

describe('when using clobber=true', function () {
before(function () {
this.originalCreateReadStream = fs.createReadStream;
});

after(function () {
fs.createReadStream = this.originalCreateReadStream;
});

it('the copy is complete after callback', function (cb) {
ncp(src, out, {clobber: true}, function(err) {
fs.createReadStream = function() {
cb(new Error('createReadStream after callback'));
};
assert.ifError(err);
process.nextTick(cb);
});
});
});

describe('when using clobber=false', function () {
it('the copy is completed successfully', function (cb) {
ncp(src, out, function() {
Expand Down

1 comment on commit 3c88d8a

@jprichardson
Copy link

Choose a reason for hiding this comment

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

Awesome. Added to fs-extra: jprichardson/node-fs-extra@f2c2c58 Thanks :)

Please sign in to comment.