Skip to content

Commit

Permalink
[Test] : UserEntityFixture pk 설정 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
wellbeing-dough committed Dec 6, 2023
1 parent 919248f commit 7d59e92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class UserRepositoryTest {
@Test
void 유저가_회원가입한다() {
// given
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L);
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성();

// when
UserEntity saveUser = userRepository.save(user);
Expand All @@ -36,11 +36,11 @@ class UserRepositoryTest {
@Test
void 식별자값으로_유저를_조회한다() {
// given
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L);
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성();
userRepository.save(user);

// when
UserEntity findUserById = userRepository.findById(1L).orElseThrow(UserNotFoundException::new);
UserEntity findUserById = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new);

// then
assertAll(
Expand All @@ -51,7 +51,7 @@ class UserRepositoryTest {
@Test
void 이메일로_유저를_조회한다() {
// given
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L);
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성();
userRepository.save(user);

// when
Expand All @@ -66,7 +66,7 @@ class UserRepositoryTest {
@Test
void 닉네임으로_유저를_조회한다() {
// given
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L);
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성();
userRepository.save(user);

// when
Expand All @@ -81,7 +81,7 @@ class UserRepositoryTest {
@Test
void 이메일로_유저_존재여부를_확인한다() {
// given
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L);
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성();
userRepository.save(user);

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,12 @@ void createPost_success() {
ArgumentCaptor<StudyPostEntity> captor = ArgumentCaptor.forClass(StudyPostEntity.class);

// when
Long createdPostId = studyPostService.createPost(info);
studyPostService.createPost(info);

// then
verify(studyPostRepository, times(1))
.save(captor.capture());
StudyPostEntity capturedStudyPost = captor.getValue();
assertEquals("정보처리기사", capturedStudyPost.getTitle());

assertNotNull(createdPostId);

}
}

0 comments on commit 7d59e92

Please sign in to comment.