-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: always catch and emit cache write errors in promise (#288)
- Loading branch information
1 parent
f5135ba
commit ed73ef5
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
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
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,24 @@ | ||
const nock = require('nock') | ||
const t = require('tap') | ||
const path = require('path') | ||
|
||
const fetch = require('../') | ||
nock.disableNetConnect() | ||
|
||
t.beforeEach(() => nock.cleanAll()) | ||
t.test('catches error for inaccessible cache', async t => { | ||
// a file for the cache which wont work | ||
const cache = t.testdir({ | ||
file: '', | ||
}) | ||
const req = nock('http://localhost') | ||
.get('/foo') | ||
.reply(() => [200, Buffer.from('text')]) | ||
|
||
const res = await fetch('http://localhost/foo', { | ||
cachePath: path.resolve(cache, 'file'), | ||
}) | ||
|
||
await t.rejects(res.text(), { code: 'ENOTDIR' }) | ||
t.ok(req.isDone()) | ||
}) |