dont error if ejectFromCache is called when the response is already not cached
This commit is contained in:
parent
76978176d5
commit
1df05c2584
@ -25,8 +25,14 @@ class Response {
|
||||
return this.bodyBuffer;
|
||||
}
|
||||
|
||||
ejectFromCache() {
|
||||
return fs.promises.unlink(this.cacheFilePath);
|
||||
async ejectFromCache() {
|
||||
try {
|
||||
await fs.promises.unlink(this.cacheFilePath);
|
||||
} catch (err) {
|
||||
if (err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,14 @@ describe('Cache tests', function() {
|
||||
res = await fetch(TWO_HUNDRED_URL);
|
||||
assert.strictEqual(res.fromCache, true);
|
||||
});
|
||||
|
||||
it('Does not error if rejecting from cache twice', async function() {
|
||||
res = await fetch(TWO_HUNDRED_URL);
|
||||
assert.strictEqual(res.fromCache, false);
|
||||
|
||||
await res.ejectFromCache();
|
||||
await res.ejectFromCache();
|
||||
});
|
||||
}).timeout(10000);
|
||||
|
||||
describe('Data tests', function() {
|
||||
|
Reference in New Issue
Block a user