0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-01 15:12:40 +00:00

Add account check to Google File not found error

This commit is contained in:
G.Ambatte
2023-06-26 20:40:11 +12:00
parent a3b2c6987f
commit e88e7f852c
3 changed files with 17 additions and 8 deletions

View File

@@ -59,7 +59,7 @@ const api = {
// Throw any error caught while attempting to retrieve Google brew.
if(googleError) {
const reason = googleError.errors[0].reason;
throw { ...googleError, HBErrorCode: reason == 'notFound' ? '02' : '01', authors: stub?.authors };
throw { ...googleError, HBErrorCode: reason == 'notFound' ? '02' : '01', authors: stub?.authors, account: req.account.username };
}
// Combine the Homebrewery stub with the google brew, or if the stub doesn't exist just use the google brew
stub = stub ? _.assign({ ...api.excludeStubProps(stub), stubbed: true }, api.excludeGoogleProps(googleBrew)) : googleBrew;

View File

@@ -543,7 +543,7 @@ brew`);
describe('deleteBrew', ()=>{
it('should handle case where fetching the brew returns an error', async ()=>{
api.getBrew = jest.fn(()=>async ()=>{ throw {message: 'err', HBErrorCode: '02' }; });
api.getBrew = jest.fn(()=>async ()=>{ throw { message: 'err', HBErrorCode: '02' }; });
api.getId = jest.fn(()=>({ id: '1', googleId: '2' }));
model.deleteOne = jest.fn(async ()=>{});
const next = jest.fn(()=>{});