Skip to content

Commit

Permalink
fix: return when not found city
Browse files Browse the repository at this point in the history
  • Loading branch information
enieber committed Mar 9, 2024
1 parent b8260ff commit cd9f448
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pages/api/cptec/v1/clima/previsao/semana/[lat]/[long].js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ const action = async (request, response) => {
throw err;
}

throw new InternalError({
message: 'Erro ao buscar previsões para a cidade',
type: 'weather_error',
name: 'CITY_WEATHER_PREDICTIONS_ERROR',
throw new NotFoundError({
message: 'Cidade não localizada',
type: 'city_error',
name: 'CITY_NOT_FOUND',
});
}
};
Expand Down
9 changes: 5 additions & 4 deletions tests/cpetc/previsao-v1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ describe('weather prediction v1 (E2E)', () => {
} catch (error) {
const { response } = error;

expect(response.status).toBe(500);
expect(response.status).toBe(404);

expect(response.data).toMatchObject({
name: 'CITY_WEATHER_PREDICTIONS_ERROR',
type: 'weather_error',
message: 'Cidade não localizada',
type: 'city_error',
name: 'CITY_NOT_FOUND',
});
}
}
});

test('GET with invalid long', async () => {
Expand Down

0 comments on commit cd9f448

Please sign in to comment.