Skip to content

Commit

Permalink
Merge pull request #108 from kakao-tech-campus-2nd-step3/feature/106-โ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆlike-concurrency

fix: ๋น„๊ด€์  ๋ฝ ์ ์šฉ์œผ๋กœ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜์ •
  • Loading branch information
peeerr authored Nov 14, 2024
2 parents 8a31893 + 2c935a7 commit 4749749
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void should_FindLike_When_FilteringByMemberAndDiary() {
likeRepository.save(like);

// when
Optional<Like> foundLike = likeRepository.findByMemberIdAndDiaryId(member.getId(), diary.getId());
Optional<Like> foundLike = likeRepository.findByMemberIdAndDiaryIdWithLock(member.getId(), diary.getId());

// then
assertThat(foundLike).isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void should_AddLike_When_NotLiked() {

given(memberRepository.findById(memberId)).willReturn(Optional.of(member));
given(diaryRepository.findById(diaryId)).willReturn(Optional.of(diary));
given(likeRepository.findByMemberIdAndDiaryId(memberId, diaryId))
given(likeRepository.findByMemberIdAndDiaryIdWithLock(memberId, diaryId))
.willReturn(Optional.empty());

// when
Expand Down Expand Up @@ -122,7 +122,7 @@ void should_RemoveLike_When_AlreadyLiked() {

given(memberRepository.findById(memberId)).willReturn(Optional.of(member));
given(diaryRepository.findById(diaryId)).willReturn(Optional.of(diary));
given(likeRepository.findByMemberIdAndDiaryId(memberId, diaryId))
given(likeRepository.findByMemberIdAndDiaryIdWithLock(memberId, diaryId))
.willReturn(Optional.of(like));

// when
Expand All @@ -138,9 +138,7 @@ void should_ThrowException_When_DiaryNotPublic() {
// given
Long memberId = 1L;
Long diaryId = 1L;
Member member = Member.builder()
.id(memberId)
.build();

Diary diary = Diary.builder()
.id(diaryId)
.isPublic(false)
Expand Down

0 comments on commit 4749749

Please sign in to comment.