-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
내 비밀번호 변경 API 구현 #94
내 비밀번호 변경 API 구현 #94
Conversation
public void changePassword(String password) { | ||
this.password = password; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 어떨까요?
public void changePassword(String password) { | |
this.password = password; | |
} | |
public void changePassword(String encodedPassword) { | |
this.password = encodedPassword; | |
} | |
UserDto userUpdated = userCommandService.updatePassword(userPrincipal.getUserId(), | ||
updatePasswordRequest.getPassword()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 줄 정리 좀 해주시면 이쁠 거 같아요? 아니면 말구요 ㅎ;
UserDto userUpdated = userCommandService.updatePassword(userPrincipal.getUserId(), | |
updatePasswordRequest.getPassword()); | |
UserDto userUpdated = userCommandService.updatePassword( | |
userPrincipal.getUserId(), | |
updatePasswordRequest.getPassword() | |
); |
@Test | ||
void 주어진_유저_ID와_새로운_비밀번호로_유저의_비밀번호를_변경한다_존재하지_않는_유저라면_예외가_발생한다() throws Exception { | ||
// given | ||
Long userId = 1L; | ||
String newPassword = "newPwd1234!!"; | ||
given(userQueryService.getById(userId)).willThrow(UserNotFoundByIdException.class); | ||
|
||
// when | ||
Throwable t = catchThrowable(() -> sut.updatePassword(userId, newPassword)); | ||
|
||
// then | ||
then(userQueryService).should().getById(userId); | ||
verifyEveryMocksShouldHaveNoMoreInteractions(); | ||
assertThat(t).isInstanceOf(UserNotFoundByIdException.class); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 아까 리뷰했던거랑 비슷한데요.
경우에 따라 조금씩 다를 수는 있는데 unit test에서 중점적인 것들 중 하나는 "테스트 대상의 역할만을 검증"하는 거라고 생각해요.
지금 이 케이스 같은 경우, 유저를 조회했는데 없는 경우 에러를 발생시키는 건 getById
method의 책임이자 역할이라고 보기 때문에 굳이? 작성 안해도 되지 않나 싶습니다.
🔥 Related Issue
🏃 Task
📄 Reference