Skip to content

Commit

Permalink
fix: 일반적인 에러 응답상황 Error객체 던지도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mintaek22 committed Dec 3, 2024
1 parent debe3e3 commit 081e8cf
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions BE/test/interceptor/user-db-connection.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ describe('UserDBConnectionInterceptor - 응답 처리', () => {
it('일반 에러에 대해 rollback이 호출되지 않는다.', async () => {
//given
mockCallHandler.handle.mockImplementation(() =>
throwError(() => new BadGatewayException()),
throwError(() => new Error()),
);

//when
Expand All @@ -191,16 +191,14 @@ describe('UserDBConnectionInterceptor - 응답 처리', () => {
const rollbackSpy = jest.spyOn(TEST_REQUEST.dbConnection, 'rollback');

//then
await expect(lastValueFrom(observable)).rejects.toThrow(
BadGatewayException,
);
await expect(lastValueFrom(observable)).rejects.toThrow(Error());
expect(rollbackSpy).not.toHaveBeenCalled();
});

it('일반 에러에 대해 커넥션이 종료된다.', async () => {
//given
mockCallHandler.handle.mockImplementation(() =>
throwError(() => new BadGatewayException()),
throwError(() => new Error()),
);

//when
Expand All @@ -211,9 +209,7 @@ describe('UserDBConnectionInterceptor - 응답 처리', () => {
const endSpy = jest.spyOn(TEST_REQUEST.dbConnection, 'end');

//then
await expect(lastValueFrom(observable)).rejects.toThrow(
BadGatewayException,
);
await expect(lastValueFrom(observable)).rejects.toThrow(Error());
expect(endSpy).toHaveBeenCalled();
});
});

0 comments on commit 081e8cf

Please sign in to comment.