Skip to content

Commit

Permalink
fix(Test): PurchaseHotdealtest 단일 구매자의 구매 테스트 필드 선언 구조 변경
Browse files Browse the repository at this point in the history
- GithubActions의 성능이 좋지 않아 트랜잭션이 밀려 동시성 문제에 걸리는 버그 발견
- 테스트별로 product 객체를 새로 만들고 할당해 해결
  • Loading branch information
zzzzseong committed Feb 2, 2024
1 parent c8c7b91 commit 0e47162
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,32 @@ void tearDown() {
@DisplayName("단일 구매자의 구매 테스트")
class SinglePurchaseTest {

private Product product;
private Hotdeal hotdeal;
private PurchaseHotdealRequestDto requestDto;

@BeforeEach
void setUp() {
product = productRepository.save(
Product.builder()
.title(TEST_PRODUCT_TITLE)
.content(TEST_PRODUCT_CONTENT)
.price(TEST_PRICE)
.quantity(TEST_QUANTITY)
.build()
);
hotdeal = hotdealRepository.save(
HotdealTestUtil.createHotdeal(TEST_START_DAY, TEST_DUE_DAY, TEST_DEAL_QUANTITY,
TEST_SALE, product));
requestDto = HotdealTestUtil.createTestPurchaseHotdealRequestDto(
hotdeal.getId(), 3);
}

@AfterEach
void tearDown() {
purchaseRepository.deleteAll();
}

private Product product = productRepository.save(ANOTHER_TEST_PRODUCT);
private Hotdeal hotdeal = hotdealRepository.save(
HotdealTestUtil.createHotdeal(TEST_START_DAY, TEST_DUE_DAY, TEST_DEAL_QUANTITY,
TEST_SALE, product));

private PurchaseHotdealRequestDto requestDto = HotdealTestUtil.createTestPurchaseHotdealRequestDto(
hotdeal.getId(), 3);

@Test
@DisplayName("성공 - 구매자가 구매한 상품이 구매 목록에 추가되는지 확인")
void purchaseHotdeal() {
Expand Down

0 comments on commit 0e47162

Please sign in to comment.