Skip to content

Commit

Permalink
test when fs.stat errors
Browse files Browse the repository at this point in the history
  • Loading branch information
joshhunt committed Mar 22, 2024
1 parent 8b6146b commit 619084d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,28 @@ function suite(moduleName) {
stream.pipeline([gs, concat()], assert);
});

it('destroys the stream if walker errors when following symlink', function (done) {
var expectedError = new Error('Stubbed error');

var gs = globStream('./fixtures/**/*.dmc', { cwd: dir });

function stubError(dirpath, cb) {
cb(expectedError);
}

var spy = sinon.spy(gs, 'destroy');
sinon.stub(fs, 'stat').callsFake(stubError);

function assert(err) {
sinon.restore();
expect(spy.called).toEqual(true);
expect(err).toBe(expectedError);
done();
}

stream.pipeline([gs, concat()], assert);
});

it('does not emit an error if stream is destroyed without an error', function (done) {
var gs = globStream('./fixtures/**/*.dmc', { cwd: dir });

Expand Down

0 comments on commit 619084d

Please sign in to comment.