-
Notifications
You must be signed in to change notification settings - Fork 0
[Mod] preparationUser api 테스트코드 작성 #121
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
Conversation
preparationUser1Id, newUser, "세면", 10, preparationUser2)); | ||
preparationUserRepository.save(preparationUser1); | ||
preparationUserRepository.save(preparationUser2); | ||
preparationUserRepository.save(preparationUser3); |
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.
이 부분 중복코드로 보여지는데 이렇게 짜신 이유가 있을까요?
PreparationUser preparationUser3 = preparationUserRepository.save(new PreparationUser( preparationUser3Id, newUser, "화장", 10, null));
new를 통해 생성자로 객체 생성하고 바로 save()로 JPA에 저장하는 코드인데 바로 아래줄에
preparationUserRepository.save(preparationUser3);
위 코드로 save()로 반환받은 저장 객체를 다시 저장하신 이유가 궁금합니다
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.
처음에는 객체를 생성한 후 별도로 저장하는 코드가 있었고, 이후에 save()를 즉시 호출하는 방식으로 변경했는데, 기존코드가 수정이 되지 않았네요. 다시 커밋했습니다.
UUID.randomUUID(), newUser, "알림확인", 10, preparationUser2)); | ||
preparationUserRepository.save(preparationUser1); | ||
preparationUserRepository.save(preparationUser2); | ||
preparationUserRepository.save(preparationUser3); |
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.
이 부분도 왜 동일한 객체를 두번 save()하는지 궁금합니다
H2를 사용하여 테스트 진행하셨다고 하셨는데 application.properties에서 DB연결하는 속성을 수정하셔서 하셨는지 아니면 테스트용 properties를 로컬에서 따로 만드셨는지 혹은 다른 방법으로 하셨는지 궁금합니다 |
처음 의도는 H2를 사용하는거였는데 H2를 사용할시 수정해야할 부분이 많아져서 로컬 DB를 접근하는 방식으로 바뀌었는데 PR에 첫 의도대로 작성하게 되었네요. 수정하였습니다! |
로컬로 세팅하신 MySQL 말씀하시는거죠? |
네 맞습니다! |
추가한 코드
PreparationUserServiceTest 결과
PreparationUserControllerTest 결과
close #102