From 4088dea938768977caf302a01ddac76ed5e174ea Mon Sep 17 00:00:00 2001 From: inhooo00 Date: Sun, 14 Jul 2024 21:17:18 +0900 Subject: [PATCH] =?UTF-8?q?Feat(#20):=20AuthMemberService=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/AuthMemberServiceTest.java | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/test/java/shop/kkeujeok/kkeujeokbackend/auth/application/AuthMemberServiceTest.java b/src/test/java/shop/kkeujeok/kkeujeokbackend/auth/application/AuthMemberServiceTest.java index 763a2fb4..6f70f32e 100644 --- a/src/test/java/shop/kkeujeok/kkeujeokbackend/auth/application/AuthMemberServiceTest.java +++ b/src/test/java/shop/kkeujeok/kkeujeokbackend/auth/application/AuthMemberServiceTest.java @@ -65,6 +65,21 @@ void setUp() { verify(memberRepository).save(any(Member.class)); } + @DisplayName("회원 정보가 올바르게 저장되는지 확인합니다.") + @Test + void 회원_정보가_올바르게_저장되는지_확인합니다() { + when(memberRepository.findByEmail(anyString())).thenReturn(Optional.empty()); + when(memberRepository.save(any(Member.class))).thenAnswer(invocation -> invocation.getArgument(0)); + + MemberLoginResDto result = authMemberService.saveUserInfo(userInfo, provider); + + assertThat(result).isNotNull(); + assertThat(result.findMember().getEmail()).isEqualTo(userInfo.email()); + assertThat(result.findMember().getName()).isEqualTo(userInfo.name()); + verify(memberRepository).findByEmail(userInfo.email()); + verify(memberRepository).save(any(Member.class)); + } + @DisplayName("소셜 타입이 일치하지 않는 경우 예외를 던집니다.") @Test void 소셜_타입이_일치하지_않는_경우_예외를_던집니다() { @@ -76,11 +91,35 @@ void setUp() { verify(memberRepository).findByEmail(userInfo.email()); } + @DisplayName("이메일이 null인 경우 예외를 던진다.") @Test - @DisplayName("이메일이 null인 경우 테스트") - void testNullEmail() { - UserInfo invalidUserInfo = new UserInfo(null, "Test User", "testUser", "testPicture"); + void 이메일이_null인_경우_예외를_던진다() { + UserInfo invalidUserInfo = new UserInfo(null, "이름", "사진", "닉네임"); assertThrows(RuntimeException.class, () -> authMemberService.saveUserInfo(invalidUserInfo, provider)); } + + @DisplayName("이름이 null인 경우 예외를 던진다.") + @Test + void 이름이_null인_경우_예외를_던진다() { + UserInfo userInfoWithNullName = new UserInfo("이메일", null, "사진", "닉네임"); + + assertThrows(RuntimeException.class, () -> authMemberService.saveUserInfo(userInfoWithNullName, provider)); + } + + @DisplayName("사진이 null인 경우 예외를 던진다.") + @Test + void 사진이_null인_경우_예외를_던진다() { + UserInfo userInfoWithNullPicture = new UserInfo("이메일", "이름", null, "닉네임"); + + assertThrows(RuntimeException.class, () -> authMemberService.saveUserInfo(userInfoWithNullPicture, provider)); + } + + @DisplayName("닉네임이 null인 경우 예외를 던진다.") + @Test + void 닉네임이_null인_경우_예외를_던진다() { + UserInfo userInfoWithNullNickname = new UserInfo("이메일", "이름", "사진", null); + + assertThrows(RuntimeException.class, () -> authMemberService.saveUserInfo(userInfoWithNullNickname, provider)); + } }