Skip to content

Commit

Permalink
[refactor] 유저 삭제 테스트 책임 이관 (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh committed Oct 31, 2024
1 parent 994c024 commit a0f3498
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/test/java/org/sopt/app/application/UserServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@ void SUCCESS_upsertRegisteredUser() {
Assertions.assertEquals(anyUserId, result);
}

@Test
@DisplayName("SUCCESS_유저 삭제")
void SUCCESS_deleteUser() {
//given
User user = new User();

//then
Assertions.assertDoesNotThrow(() -> userService.deleteUser(user));
}

@Test
@DisplayName("SUCCESS_플레이그라운드 토큰 조회")
void SUCCESS_getPlaygroundToken() {
Expand Down
50 changes: 50 additions & 0 deletions src/test/java/org/sopt/app/application/UserWithdrawTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.sopt.app.application;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.sopt.app.application.user.UserWithdrawService;
import org.sopt.app.common.event.EventPublisher;
import org.sopt.app.interfaces.postgres.UserRepository;

@ExtendWith(MockitoExtension.class)
class UserWithdrawTest {

@Mock
private EventPublisher eventPublisher;

@Mock
private UserRepository userRepository;

@InjectMocks
private UserWithdrawService userWithdrawService;

@Test
void SUCCESS_유저_탈퇴시_유저_삭제() {
//given
final Long userId = 1L;

// when
userWithdrawService.withdrawUser(userId);

//then
verify(userRepository).deleteById(userId);
}

@Test
void SUCCESS_유저_탈퇴시_스탬프_삭제_이벤트_발생() {
//given
final Long userId = 1L;

// when
userWithdrawService.withdrawUser(userId);

//then
verify(eventPublisher).raise(any());
}
}

0 comments on commit a0f3498

Please sign in to comment.