Skip to content

Commit

Permalink
refactor: events.clear()를 @AfterEach로 추출
Browse files Browse the repository at this point in the history
  • Loading branch information
hanueleee committed Oct 16, 2023
1 parent 431f46a commit 906ae95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 6 additions & 0 deletions backend/src/test/java/com/funeat/common/EventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.funeat.review.application.ReviewService;
import com.funeat.review.persistence.ReviewRepository;
import com.funeat.tag.persistence.TagRepository;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -45,6 +46,11 @@ public class EventTest {
@Autowired
protected ReviewRepository reviewRepository;

@AfterEach
void tearDown() {
events.clear();
}

protected Product 단일_상품_저장(final Product product) {
return productRepository.save(product);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class 리뷰_삭제_이벤트_발행 {
// then
final var count = events.stream(ReviewDeleteEvent.class).count();
assertThat(count).isEqualTo(1);
events.clear();
}

@Test
Expand All @@ -70,7 +69,6 @@ class 리뷰_삭제_이벤트_발행 {
// then
final var count = events.stream(ReviewDeleteEvent.class).count();
assertThat(count).isEqualTo(0);
events.clear();
}
}

Expand All @@ -92,7 +90,6 @@ class 이미지_삭제_로직_작동 {

// then
verify(uploader, timeout(1000).times(1)).delete(any());
events.clear();
}

@Test
Expand All @@ -110,7 +107,6 @@ class 이미지_삭제_로직_작동 {

// then
verify(uploader, timeout(1000).times(0)).delete(any());
events.clear();
}

@Test
Expand All @@ -132,7 +128,6 @@ class 이미지_삭제_로직_작동 {

// then
assertThat(reviewRepository.findById(review.getId())).isEmpty();
events.clear();
}
}
}

0 comments on commit 906ae95

Please sign in to comment.