Skip to content
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

feat: Test DisplayName 설정 및 중복 좋아요 등록 시도 에러 처리 추가 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seocylucky
Copy link
Member

@seocylucky seocylucky commented Feb 14, 2025

📌 PR 타입 (하나 이상 선택)

  • 기능 추가
  • 버그 수정
  • 의존성, 환경 변수, 빌드 관련 코드 업데이트
  • 기타 사소한 수정

🔗 관련 이슈 링크

Close # ❌

💜 개요

  • 현식님이 말해주신 Test DisplayName 설정 및 중복 좋아요 등록 시도 에러 처리 추가 작업을 하였습니다.

🔁 변경 사항

    @Test
    @DisplayName("같은 userId가 동일한 postId에 대해 중복 좋아요 시도 시 예외 처리 테스트")
    void testAddLikeWithDuplicateUser() {
        when(userLikeRepository.findByUserIdAndPostId(1L, 100L)).thenReturn(Optional.of(userLike));

        IllegalStateException exception = assertThrows(IllegalStateException.class, () -> {
            userLikeService.addLike(1L, 100L);
        });

        assertEquals("🚀 중복 좋아요 등록 시도 - userId: 1, postId: 100", exception.getMessage());

        verify(userLikeRepository, never()).save(any(UserLike.class));
    }

📸 스크린샷 (선택)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant